dépôts
/
lhc
/
web
/
wiklou.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge "Clarify what $params is for ApiBase methods to get Title/WikiPage"
[lhc/web/wiklou.git]
/
maintenance
/
deleteArchivedFiles.php
diff --git
a/maintenance/deleteArchivedFiles.php
b/maintenance/deleteArchivedFiles.php
index
92f1a91
..
0f33a14
100644
(file)
--- a/
maintenance/deleteArchivedFiles.php
+++ b/
maintenance/deleteArchivedFiles.php
@@
-21,7
+21,6
@@
*
* @file
* @ingroup Maintenance
*
* @file
* @ingroup Maintenance
- * @author Aaron Schulz
*/
require_once __DIR__ . '/Maintenance.php';
*/
require_once __DIR__ . '/Maintenance.php';
@@
-54,7
+53,7
@@
class DeleteArchivedFiles extends Maintenance {
$this->output( "Searching for and deleting archived files...\n" );
$res = $dbw->select(
'filearchive',
$this->output( "Searching for and deleting archived files...\n" );
$res = $dbw->select(
'filearchive',
-
array( 'fa_id', 'fa_storage_group', 'fa_storage_key', 'fa_sha1' )
,
+
[ 'fa_id', 'fa_storage_group', 'fa_storage_key', 'fa_sha1', 'fa_name' ]
,
'',
__METHOD__
);
'',
__METHOD__
);
@@
-67,9
+66,19
@@
class DeleteArchivedFiles extends Maintenance {
continue;
}
continue;
}
+ /** @var LocalFile $file */
+ $file = $repo->newFile( $row->fa_name );
+ try {
+ $file->lock();
+ } catch ( LocalFileLockError $e ) {
+ $this->error( "Could not acquire lock on '{$row->fa_name}', skipping\n" );
+ continue;
+ }
+
$group = $row->fa_storage_group;
$id = $row->fa_id;
$group = $row->fa_storage_group;
$id = $row->fa_id;
- $path = $repo->getZonePath( 'deleted' ) . '/' . $repo->getDeletedHashPath( $key ) . $key;
+ $path = $repo->getZonePath( 'deleted' ) .
+ '/' . $repo->getDeletedHashPath( $key ) . $key;
if ( isset( $row->fa_sha1 ) ) {
$sha1 = $row->fa_sha1;
} else {
if ( isset( $row->fa_sha1 ) ) {
$sha1 = $row->fa_sha1;
} else {
@@
-81,12
+90,12
@@
class DeleteArchivedFiles extends Maintenance {
$inuse = $dbw->selectField(
'oldimage',
'1',
$inuse = $dbw->selectField(
'oldimage',
'1',
- array(
+ [
'oi_sha1' => $sha1,
$dbw->bitAnd( 'oi_deleted', File::DELETED_FILE ) => File::DELETED_FILE
'oi_sha1' => $sha1,
$dbw->bitAnd( 'oi_deleted', File::DELETED_FILE ) => File::DELETED_FILE
-
)
,
+
]
,
__METHOD__,
__METHOD__,
- array( 'FOR UPDATE' )
+ [ 'FOR UPDATE' ]
);
$needForce = true;
);
$needForce = true;
@@
-96,6
+105,7
@@
class DeleteArchivedFiles extends Maintenance {
$this->output( "Notice - file '$key' is still in use\n" );
} elseif ( !$repo->quickPurge( $path ) ) {
$this->output( "Unable to remove file $path, skipping\n" );
$this->output( "Notice - file '$key' is still in use\n" );
} elseif ( !$repo->quickPurge( $path ) ) {
$this->output( "Unable to remove file $path, skipping\n" );
+ $file->unlock();
continue; // don't delete even with --force
} else {
$needForce = false;
continue; // don't delete even with --force
} else {
$needForce = false;
@@
-105,12
+115,14
@@
class DeleteArchivedFiles extends Maintenance {
if ( $this->hasOption( 'force' ) ) {
$this->output( "Got --force, deleting DB entry\n" );
} else {
if ( $this->hasOption( 'force' ) ) {
$this->output( "Got --force, deleting DB entry\n" );
} else {
+ $file->unlock();
continue;
}
}
$count++;
continue;
}
}
$count++;
- $dbw->delete( 'filearchive', array( 'fa_id' => $id ), __METHOD__ );
+ $dbw->delete( 'filearchive', [ 'fa_id' => $id ], __METHOD__ );
+ $file->unlock();
}
$this->commitTransaction( $dbw, __METHOD__ );
}
$this->commitTransaction( $dbw, __METHOD__ );