r22091 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r22090‎ | r22091 | r22092 >
Date:00:36, 11 May 2007
Author:aaron
Status:old
Tags:
Comment:
*nest deletion per row, to avoid racing
Modified paths:
  • /trunk/phase3/maintenance/deleteArchivedFiles.inc (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/deleteArchivedFiles.inc
@@ -25,16 +25,18 @@
2626
2727 # Get "active" revisions from the filearchive table
2828 echo( "Searching for and deleting archived files...\n" );
29 - $res = $dbw->query( "SELECT fa_storage_group,fa_storage_key FROM $tbl_arch" );
 29+ $res = $dbw->query( "SELECT fa_id,fa_storage_group,fa_storage_key FROM $tbl_arch" );
3030 while( $row = $dbw->fetchObject( $res ) ) {
3131 $key = $row->fa_storage_key;
3232 $group = $row->fa_storage_group;
 33+ $id = $row->fa_id;
3334
3435 $store = FileStore::get( $group );
3536 if ( $store ) {
3637 $path = $store->filePath( $key );
3738 if ( $path && file_exists($path) ) {
3839 $transaction->addCommit( FSTransaction::DELETE_FILE, $path );
 40+ $dbw->query( "DELETE FROM $tbl_arch WHERE fa_id = $id" );
3941 } else {
4042 echo( "Notice - file '$key' not found in group '$group'\n" );
4143 }
@@ -46,12 +48,6 @@
4749
4850 $transaction->commit();
4951
50 -
51 - # Delete as appropriate
52 - echo( "Deleting filearchive rows..." );
53 - $dbw->query( "TRUNCATE TABLE $tbl_arch" );
54 - echo( "done.\n" );
55 -
5652 # This bit's done
5753 # Purge redundant text records
5854 $dbw->commit();