Андрей (andy) wrote in changelog,
Андрей
andy
changelog

[fotobilder] r1439: LJSV-1293 (Images are disappeared from s...

Committer: ailyin
LJSV-1293 (Images are disappeared from scrapbook): for now, get rid of a subtle race condition; not sure if this resolves it
U   trunk/bin/maint/flush_gpic_deletes.pl
Modified: trunk/bin/maint/flush_gpic_deletes.pl
===================================================================
--- trunk/bin/maint/flush_gpic_deletes.pl	2011-01-13 05:24:13 UTC (rev 1438)
+++ trunk/bin/maint/flush_gpic_deletes.pl	2011-02-08 02:51:22 UTC (rev 1439)
@@ -38,32 +38,27 @@
 }
 
 # go through gpicids that aren't on any clusters
-my @gpicid_done = ();
 foreach my $gpicid (@gpicids) {
     next if $on_cluster{$gpicid};
 
     my $g = FB::Gpic->load($gpicid) or next;
     $g->delete;
 
-    push @gpicid_done, $gpicid;
-}
+    # need to recursively delete gpics which are scaled from this one
+    my $gpic_deriv = $dbh->selectcol_arrayref(qq{
+        SELECT gpicids FROM gpic_scaled WHERE gpicido = ?
+    }, undef, $gpicid);
 
-# gpicid_done is a list of gpicids whose data has been deleted
-if (@gpicid_done) {
-    my $done_bind = join(",", map { "?" } @gpicid_done);
+    if ( $gpic_deriv && @$gpic_deriv ) {
+        FB::gpicid_delete(@$gpic_deriv)
+            or die "Error: FB::gpicid_delete failed\n";
+    }
 
-    # need to recursively delete gpics which are scaled from these
-    my @gpic_deriv = @{ $dbh->selectcol_arrayref("SELECT gpicids FROM gpic_scaled WHERE gpicido IN ($done_bind)",
-                                                 undef, @gpicid_done) || []};
-
-    FB::gpicid_delete(@gpic_deriv) or die "Error: FB::gpicid_delete failed\n"
-        if @gpic_deriv;
-
-    $dbh->do("DELETE FROM gpic_scaled WHERE gpicido IN ($done_bind)", undef, @gpicid_done);
-    $dbh->do("DELETE FROM gpic WHERE gpicid IN ($done_bind)", undef, @gpicid_done);
+    $dbh->do( 'DELETE FROM gpic_scaled WHERE gpicido = ?', undef, $gpicid );
+    $dbh->do( 'DELETE FROM gpic WHERE gpicid = ?',         undef, $gpicid );
 }
 
-# regardless of whether it was on a cluster or not, we want to delete from the gpic_delete queue
+# now, clean up the queue
 {
     my $gpicids_bind = join(",", map { "?" } @gpicids);
     $dbh->do("DELETE FROM gpic_delete WHERE gpicid IN ($gpicids_bind)", undef, @gpicids);

Tags: andy, fotobilder, pl
Subscribe
  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 0 comments