From: Aaron Schulz Date: Thu, 10 May 2007 22:10:25 +0000 (+0000) Subject: *Add a script to delete archived images X-Git-Tag: 1.31.0-rc.0~52959 X-Git-Url: http://git.cyclocoop.org/%7B%24www_url%7Dadmin/password.php?a=commitdiff_plain;h=f2f48103b1dbc77ecc0070bfd5c51350c6ebcf85;p=lhc%2Fweb%2Fwiklou.git *Add a script to delete archived images --- diff --git a/maintenance/deleteArchivedFiles.inc b/maintenance/deleteArchivedFiles.inc new file mode 100644 index 0000000000..1880ed9c23 --- /dev/null +++ b/maintenance/deleteArchivedFiles.inc @@ -0,0 +1,61 @@ +begin(); + + $transaction = new FSTransaction(); + if( !FileStore::lock() ) { + wfDebug( __METHOD__.": failed to acquire file store lock, aborting\n" ); + return false; + } + + $tbl_arch = $dbw->tableName( 'filearchive' ); + + # 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" ); + while( $row = $dbw->fetchObject( $res ) ) { + $key = $row->fa_storage_key; + $group = $row->fa_storage_group; + + $store = FileStore::get( $group ); + if ( $store ) { + $path = $store->filePath( $key ); + if ( $path && file_exists($path) ) { + $transaction->addCommit( FSTransaction::DELETE_FILE, $path ); + } else { + echo( "Notice - file '$key' not found in group '$group'\n" ); + } + } else { + echo( "Notice - invalid file storage group '$group'\n" ); + } + } + echo( "done.\n" ); + + $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(); + +} + +?> \ No newline at end of file diff --git a/maintenance/deleteArchivedFiles.php b/maintenance/deleteArchivedFiles.php new file mode 100644 index 0000000000..7aee527e81 --- /dev/null +++ b/maintenance/deleteArchivedFiles.php @@ -0,0 +1,31 @@ + \ No newline at end of file diff --git a/maintenance/deleteArchivedRevisions.inc b/maintenance/deleteArchivedRevisions.inc index 0cb1e86aab..8d89badc79 100644 --- a/maintenance/deleteArchivedRevisions.inc +++ b/maintenance/deleteArchivedRevisions.inc @@ -1,7 +1,7 @@