X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=maintenance%2FdeleteArchivedFiles.inc;h=d58e9a407ed8ae0e5f4a9bffd588440e23b659be;hb=59e93ed412e3eb46e49c121a26f62a57fa212a68;hp=e638b17cb4e4f6a7ce8af08731742ea4f0b504e3;hpb=fae05504fedd31eee393b5c2263521874c9383a8;p=lhc%2Fweb%2Fwiklou.git diff --git a/maintenance/deleteArchivedFiles.inc b/maintenance/deleteArchivedFiles.inc index e638b17cb4..d58e9a407e 100644 --- a/maintenance/deleteArchivedFiles.inc +++ b/maintenance/deleteArchivedFiles.inc @@ -27,7 +27,7 @@ * @ingroup Maintenance */ class DeleteArchivedFilesImplementation { - static public function doDelete( $output, $force ) { + public static function doDelete( $output, $force ) { # Data should come off the master, wrapped in a transaction $dbw = wfGetDB( DB_MASTER ); $dbw->begin( __METHOD__ ); @@ -35,14 +35,19 @@ class DeleteArchivedFilesImplementation { $repo = RepoGroup::singleton()->getLocalRepo(); # Get "active" revisions from the filearchive table $output->handleOutput( "Searching for and deleting archived files...\n" ); - $res = $dbw->query( "SELECT fa_id,fa_storage_group,fa_storage_key FROM $tbl_arch" ); + $res = $dbw->query( "SELECT fa_id,fa_storage_group,fa_storage_key,fa_sha1 FROM $tbl_arch" ); $count = 0; foreach ( $res as $row ) { $key = $row->fa_storage_key; $group = $row->fa_storage_group; $id = $row->fa_id; $path = $repo->getZonePath( 'deleted' ) . '/' . $repo->getDeletedHashPath( $key ) . $key; - $sha1 = substr( $key, 0, strcspn( $key, '.' ) ); + if ( isset( $row->fa_sha1 ) ) { + $sha1 = $row->fa_sha1; + } else { + // old row, populate from key + $sha1 = LocalRepo::getHashFromKey( $key ); + } // Check if the file is used anywhere... $inuse = $dbw->selectField( 'oldimage', '1', array( 'oi_sha1' => $sha1,