*nest deletion per row, to avoid racing
authorAaron Schulz <aaron@users.mediawiki.org>
Fri, 11 May 2007 00:36:21 +0000 (00:36 +0000)
committerAaron Schulz <aaron@users.mediawiki.org>
Fri, 11 May 2007 00:36:21 +0000 (00:36 +0000)
maintenance/deleteArchivedFiles.inc

index 1880ed9..7ac5f3a 100644 (file)
@@ -25,16 +25,18 @@ function DeleteArchivedFiles( $delete = false ) {
        \r
        # Get "active" revisions from the filearchive table\r
        echo( "Searching for and deleting archived files...\n" );\r
-       $res = $dbw->query( "SELECT fa_storage_group,fa_storage_key FROM $tbl_arch" );\r
+       $res = $dbw->query( "SELECT fa_id,fa_storage_group,fa_storage_key FROM $tbl_arch" );\r
        while( $row = $dbw->fetchObject( $res ) ) {\r
                $key = $row->fa_storage_key;\r
                $group = $row->fa_storage_group;\r
+               $id = $row->fa_id;\r
                \r
                $store = FileStore::get( $group );\r
                if ( $store ) {\r
                        $path = $store->filePath( $key );\r
                        if ( $path && file_exists($path) ) {\r
                                $transaction->addCommit( FSTransaction::DELETE_FILE, $path );\r
+                               $dbw->query( "DELETE FROM $tbl_arch WHERE fa_id = $id" );\r
                        } else {\r
                                echo( "Notice - file '$key' not found in group '$group'\n" );\r
                        }\r
@@ -46,12 +48,6 @@ function DeleteArchivedFiles( $delete = false ) {
        \r
        $transaction->commit();\r
        \r
-       \r
-       # Delete as appropriate\r
-       echo( "Deleting filearchive rows..." );\r
-       $dbw->query( "TRUNCATE TABLE $tbl_arch" );\r
-       echo( "done.\n" );\r
-       \r
        # This bit's done\r
        # Purge redundant text records\r
        $dbw->commit();\r