From: Aaron Schulz Date: Fri, 11 May 2007 00:36:21 +0000 (+0000) Subject: *nest deletion per row, to avoid racing X-Git-Tag: 1.31.0-rc.0~52958 X-Git-Url: http://git.cyclocoop.org//%22%22.str_replace%28%27%22%27%2C?a=commitdiff_plain;h=322df812c17aaf7cadbeeaf8b03dd2ca964750c1;p=lhc%2Fweb%2Fwiklou.git *nest deletion per row, to avoid racing --- diff --git a/maintenance/deleteArchivedFiles.inc b/maintenance/deleteArchivedFiles.inc index 1880ed9c23..7ac5f3a3bd 100644 --- a/maintenance/deleteArchivedFiles.inc +++ b/maintenance/deleteArchivedFiles.inc @@ -25,16 +25,18 @@ function DeleteArchivedFiles( $delete = false ) { # Get "active" revisions from the filearchive table echo( "Searching for and deleting archived files...\n" ); - $res = $dbw->query( "SELECT fa_storage_group,fa_storage_key FROM $tbl_arch" ); + $res = $dbw->query( "SELECT fa_id,fa_storage_group,fa_storage_key FROM $tbl_arch" ); while( $row = $dbw->fetchObject( $res ) ) { $key = $row->fa_storage_key; $group = $row->fa_storage_group; + $id = $row->fa_id; $store = FileStore::get( $group ); if ( $store ) { $path = $store->filePath( $key ); if ( $path && file_exists($path) ) { $transaction->addCommit( FSTransaction::DELETE_FILE, $path ); + $dbw->query( "DELETE FROM $tbl_arch WHERE fa_id = $id" ); } else { echo( "Notice - file '$key' not found in group '$group'\n" ); } @@ -46,12 +48,6 @@ function DeleteArchivedFiles( $delete = false ) { $transaction->commit(); - - # Delete as appropriate - echo( "Deleting filearchive rows..." ); - $dbw->query( "TRUNCATE TABLE $tbl_arch" ); - echo( "done.\n" ); - # This bit's done # Purge redundant text records $dbw->commit();