- Timestamp:
- 11/23/10 00:11:46 (14 years ago)
- Location:
- server/trunk/web
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
server/trunk/web/bin/sophie_scan
r10 r18 7 7 use Linux::Inotify2; 8 8 use POSIX ":sys_wait_h"; 9 use Getopt::Long; 9 10 10 $SIG{ALRM} = sub {}; 11 GetOptions( 12 'bdelay=i' => \my $updated_inotify, 13 'd|daemon' => \my $daemon, 14 ) or die "Wrong options"; 15 11 16 $SIG{CHLD} = sub { wait }; 12 17 13 18 my %modified_paths; 19 my $inotify = undef; 20 $updated_inotify ||= 300; 14 21 22 if ($daemon) { 23 if (fork()) { 24 exit(0); 25 } 26 } 27 28 alarm($updated_inotify); 15 29 while (1) { 16 alarm 30; 30 local $SIG{ALRM} = sub { 31 $inotify = undef; 32 warn "reparse paths"; 33 alarm($updated_inotify); 34 }; 17 35 if (update_base(keys %modified_paths)) { 18 36 %modified_paths = (); 19 37 } 20 my $inotify= inotify_path();38 $inotify ||= inotify_path(); 21 39 $inotify->poll; 22 40 } … … 35 53 warn $e->w->name; 36 54 $modified_paths{$e->w->name} = 1; 55 1; 37 56 } 38 57 ) … … 53 72 my @pkey; 54 73 { 55 my $sophie = Sophie::Base->connect; 74 my $sophie = Sophie::Base->connect or do { 75 die "cannot read config file\n"; 76 }; 56 77 @pkey = $sophie->resultset('Paths')->search( 57 78 path => [ @path ], … … 100 121 } 101 122 1 while(waitpid(-1, 0) <= 0); 123 exit(0); 102 124 } 103 125 return 1; -
server/trunk/web/lib/Sophie.pm
r16 r18 20 20 Session::State::Cookie 21 21 Compress::Zlib 22 Server23 Server::XMLRPC24 22 Authentication 25 23 /; -
server/trunk/web/lib/Sophie/Base.pm
r5 r18 5 5 use DBI; 6 6 use base qw/DBIx::Class::Schema/; 7 use FindBin qw($Bin); 7 8 8 9 __PACKAGE__->load_namespaces(); … … 17 18 sub db { 18 19 my ($self) = @_; 19 require Sophie; 20 require Config::General; 21 my $cg = Config::General->new("$Bin/../sophie.conf"); 22 my $config = { $cg->getall() }; 20 23 21 24 DBI->connect_cached( 22 'dbi:Pg:' . Sophie->config->{dbconnect},23 Sophie->config->{dbuser},24 Sophie->config->{dbpassword},25 'dbi:Pg:' . $config->{dbconnect}, 26 $config->{dbuser}, 27 $config->{dbpassword}, 25 28 { 26 29 AutoCommit => 0, -
server/trunk/web/lib/Sophie/Base/Header.pm
r10 r18 104 104 105 105 $tmp = undef; 106 return 1; 106 107 } 107 108 -
server/trunk/web/lib/Sophie/Base/RpmsPath.pm
r7 r18 113 113 } 114 114 ); 115 $remove->execute($$self, $rpm); 116 warn "deleting $rpm"; 117 $self->db->commit; 115 for (1 .. 3) { 116 if ($remove->execute($$self, $rpm)) { 117 warn "deleting $rpm"; 118 $self->db->commit; 119 return 1; 120 } 121 $self->db->rollback; 122 } 118 123 } 119 124 … … 121 126 my ($self, $rpm) = @_; 122 127 123 if (my $pkgid = $self->_add_header($rpm)) { 124 my $register = $self->db->prepare_cached( 125 q{ 126 INSERT INTO rpmfiles (d_path, filename, pkgid) 127 values (?,?,?) 128 for (1 .. 3) { 129 if (defined(my $pkgid = $self->_add_header($rpm))) { 130 $pkgid or return; 131 my $register = $self->db->prepare_cached( 132 q{ 133 INSERT INTO rpmfiles (d_path, filename, pkgid) 134 values (?,?,?) 135 } 136 ); 137 if ($register->execute($$self, $rpm, $pkgid)) { 138 warn "adding $rpm"; 139 $self->db->commit; 140 return; 128 141 } 129 ); 130 $register->execute($$self, $rpm, $pkgid); 131 132 } else { 133 } 134 warn "adding $rpm"; 135 $self->db->commit; 142 143 } 144 $self->db->rollback; 145 } 136 146 } 137 147 … … 145 155 $header or do { 146 156 warn "Cannot read " . $self->path . '/' . $rpm; 147 return ;157 return ""; 148 158 }; 149 159 … … 197 207 } 198 208 ); 199 $index_tag->execute($header->queryformat('%{PKGID}')) ;209 $index_tag->execute($header->queryformat('%{PKGID}')) or return; 200 210 $index_tag->finish; 201 211 Sophie::Base::Header->new($header->queryformat('%{PKGID}')) 202 ->addfiles_content({ path => $self->path, filename => $rpm}) ;212 ->addfiles_content({ path => $self->path, filename => $rpm}) or return; 203 213 204 214 $header->queryformat('%{PKGID}');
Note: See TracChangeset
for help on using the changeset viewer.