Changeset 42
- Timestamp:
- 11/28/10 14:59:48 (13 years ago)
- Location:
- server/trunk/web
- Files:
-
- 1 added
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
server/trunk/web/bin/sophie_scan
r18 r42 109 109 foreach my $pathkey (@{ $job }) { 110 110 my @delta = Sophie::Base::RpmsPath->new($pathkey) 111 ->find_delta;111 ->find_delta; 112 112 while (my @d = splice(@delta, 0, 25)) { 113 113 my $path = Sophie::Base::RpmsPath->new($pathkey); -
server/trunk/web/lib/Sophie.pm
r35 r42 74 74 __PACKAGE__->config->{session} = { 75 75 expires => 3600, 76 dbi_dbh => ' Base',76 dbi_dbh => 'Session', 77 77 dbi_table => 'sessions', 78 # dbi_dsn => 'dbi:Pg:' . $config->{dbconnect}, 79 # dbi_user => $config->{dbuser}, 80 # dbi_pass => $config->{dbpassword}, 78 81 }; 79 82 -
server/trunk/web/lib/Sophie/Base.pm
r26 r42 10 10 __PACKAGE__->load_namespaces(); 11 11 12 sub connection { 13 my ($class) = @_; 14 $class->SUPER::connection( 15 sub { __PACKAGE__->db }, 16 ) 17 } 18 19 sub db { 20 my ($self) = @_; 12 sub default_config { 21 13 my $config; 22 14 foreach my $file ('sophie.conf', "$Bin/../sophie.conf", … … 27 19 } 28 20 $config or die "No config found"; 21 return $config; 22 } 29 23 30 DBI->connect_cached( 31 'dbi:Pg:' . $config->{dbconnect}, 32 $config->{dbuser}, 33 $config->{dbpassword}, 34 { 35 AutoCommit => 0, 36 PrintError => 1, 37 } 38 ); 24 sub connection { 25 my ($class, $connect_info) = @_; 26 if (! $connect_info->{dsn}) { 27 my $config = default_config(); 28 $connect_info->{dsn} = 'dbi:Pg:' . $config->{dbconnect}; 29 $connect_info->{user} = $config->{dbuser}; 30 $connect_info->{password} = $config->{dbpassword}; 31 } 32 exists($connect_info->{AutoCommit}) or $connect_info->{AutoCommit} = 0; 33 $class->SUPER::connection( 34 $connect_info, 35 ) 36 } 37 38 sub db { 39 my ($self) = @_; 40 41 $self->connect->storage->dbh; 39 42 } 40 43 -
server/trunk/web/lib/Sophie/Base/Header.pm
r18 r42 13 13 my ($class, $pkgid) = @_; 14 14 15 bless( \$pkgid, $class);15 bless({ key => $pkgid }, $class); 16 16 } 17 18 sub key { $_[0]->{key} } 17 19 18 20 sub rpm_path { … … 26 28 } 27 29 ); 28 $listrpm->execute($ $self);30 $listrpm->execute($self->key); 29 31 30 32 return $listrpm->fetchall_hashref({}); … … 51 53 select (rpmqueryfiles(header)).* from rpms where pkgid = ? 52 54 }); 53 $list_file->execute($ $self);55 $list_file->execute($self->key); 54 56 55 57 my $files = $list_file->fetchall_hashref([ 'dirname', 'basename' ]); … … 92 94 $add_content->execute( 93 95 $enc && ref $enc ? encode('utf8', $enc->decode($content)) : $content, 94 $ $self,96 $self->key, 95 97 $entry->{count}) or do { 96 98 $self->db->pg_rollback_to('FILECONTENT'); -
server/trunk/web/lib/Sophie/Base/RpmsPath.pm
r39 r42 15 15 my ($class, $pathkey) = @_; 16 16 17 bless(\$pathkey, $class); 18 } 17 bless({ key => $pathkey }, $class); 18 } 19 20 sub key { $_[0]->{key} } 19 21 20 22 sub path { … … 24 26 q{select path from d_path where d_path_key = ?} 25 27 ); 26 $sth->execute($ $self);28 $sth->execute($self->key); 27 29 my $res = $sth->fetchrow_hashref; 28 30 $sth->finish; … … 36 38 q{select * from rpmfiles where d_path = ?} 37 39 ); 38 $sth->execute($ $self);40 $sth->execute($self->key); 39 41 $sth->fetchall_hashref([ 'filename' ]); 40 42 } … … 101 103 $self->db->prepare_cached(q{ 102 104 update d_path set updated = now() where d_path_key = ? 103 })->execute($ $self);105 })->execute($self->key); 104 106 $self->db->commit; 105 107 } … … 114 116 ); 115 117 for (1 .. 3) { 116 if ($remove->execute($ $self, $rpm)) {118 if ($remove->execute($self->key, $rpm)) { 117 119 warn "deleting $rpm"; 118 120 $self->db->commit; … … 135 137 } 136 138 ); 137 if ($register->execute($ $self, $rpm, $pkgid)) {139 if ($register->execute($self->key, $rpm, $pkgid)) { 138 140 warn "adding $rpm"; 139 141 $self->db->commit; -
server/trunk/web/lib/Sophie/Controller/Admin.pm
r41 r42 2 2 use Moose; 3 3 use namespace::autoclean; 4 use YAML qw/freeze thaw/; 4 5 5 6 BEGIN {extends 'Catalyst::Controller'; } … … 89 90 } 90 91 91 @{ $c->stash->{xmlrpc} } =92 $c->stash->{xmlrpc} = [ 92 93 $c->model('Base')->resultset('Distribution') 93 94 ->search($distribution ? (name => $distribution) : ()) … … 97 98 ->search_related('MediasPaths') 98 99 ->search_related('Paths')->get_column('path') 99 ->all ;100 ->all ]; 100 101 } 101 102 … … 156 157 ->search_related('Release', version => $version) 157 158 ->search_related('Arch', arch => $arch) 158 ->search_related('Medias', label => $label)-> nextor return;159 ->search_related('Medias', label => $label)->find or return; 159 160 160 161 my $rspath = $c->model('Base')->resultset('Paths') … … 162 163 return; 163 164 }; 164 my $new = $c->model('Base')->resultset('MediasPaths')->new({ 165 Medias => $med, 166 Paths => $rspath, 167 }); 168 $new->delete; 165 my $new = $c->model('Base')->resultset('MediasPaths')->search({ 166 d_media => $med->d_media_key, 167 d_path => $rspath->d_path_key, 168 })->next->delete; 169 169 170 170 $c->model('Base')->storage->dbh->commit; … … 177 177 } 178 178 179 sub dump_distrib : XMLRPC { 180 my ($self, $c, $distribution, $version, $arch) = @_; 181 182 if (!ref $distribution) { 183 $distribution = { 184 distribution => $distribution, 185 release => $version, 186 arch => $arch, 187 }; 188 } 189 190 my $ref = { 191 distrib => $distribution, 192 }; 193 194 $ref->{media} = $c->forward('/distrib/struct', [ $distribution ]); 195 196 foreach (@{ $ref->{media} || []}) { 197 warn $_->{label}; 198 $ref->{path}{$_->{label}} = $c->forward('list_path', [ $distribution, 199 $_->{label} ]); 200 } 201 202 $c->stash->{xmlrpc} = freeze($ref); 203 } 204 205 sub clean_distrib : XMLRPC { 206 my ($self, $c, $distribution, $version, $arch) = @_; 207 208 if (!ref $distribution) { 209 $distribution = { 210 distribution => $distribution, 211 release => $version, 212 arch => $arch, 213 }; 214 } 215 216 my $rsdist = $c->model('Base')->resultset('Distribution') 217 ->search(name => $distribution->{distribution}) 218 ->search_related('Release', version => $distribution->{release}) 219 ->search_related('Arch', arch => $distribution->{arch}) 220 ->search_related('Medias'); 221 222 my $new = $c->model('Base')->resultset('MediasPaths')->search({ 223 d_media => { IN => $rsdist->get_column('d_media_key')->as_query }, 224 })->delete; 225 226 # $c->model('Base')->storage->dbh->rollback; 227 228 } 229 230 sub load_distrib : XMLRPC { 231 my ( $self, $c, $dump ) = @_; 232 233 my $ref = thaw($dump); 234 235 warn keys %{$ref->{path}}; 236 237 $c->forward('clean_distrib', [ $ref->{distrib} ]); 238 239 $c->forward('create', [ 240 $ref->{distrib}{distribution}, 241 $ref->{distrib}{release}, 242 $ref->{distrib}{arch}, 243 ]); 244 245 foreach my $media (@{ $ref->{media} || []}) { 246 $c->forward('add_media', [ $ref->{distrib}, $media ]); 247 } 248 foreach my $media (keys %{ $ref->{path} || [] }) { 249 foreach my $path (@{ $ref->{path}{$media} || [] }) { 250 $c->forward('media_path', [ $ref->{distrib}, $media, $path ]); 251 } 252 } 253 254 #$c->model('Base')->storage->dbh->rollback; 255 } 256 179 257 =head1 AUTHOR 180 258 -
server/trunk/web/lib/Sophie/Controller/Distrib.pm
r41 r42 74 74 label => $_->label, 75 75 group_label => $_->group_label, 76 key => $_->d_media_key,77 76 } 78 77 } $rs->all ]; -
server/trunk/web/lib/Sophie/Controller/Root.pm
r41 r42 88 88 } 89 89 $c->stash->{data} = $c->stash->{xmlrpc}; 90 $c->model('Base')->storage->dbh-> commit;90 $c->model('Base')->storage->dbh->rollback; 91 91 } 92 92 -
server/trunk/web/lib/Sophie/Model/Base.pm
r41 r42 7 7 schema_class => 'Sophie::Base', 8 8 connect_info => { 9 dsn => 'toto', 9 dsn => '', 10 private_cache_key => __PACKAGE__, 11 AutoCommit => 0, 10 12 }, 11 13 );
Note: See TracChangeset
for help on using the changeset viewer.