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 "API: Internationalize all remaining core API modules"
[lhc/web/wiklou.git]
/
maintenance
/
cleanupUploadStash.php
diff --git
a/maintenance/cleanupUploadStash.php
b/maintenance/cleanupUploadStash.php
index
d8bfd98
..
24b63a8
100644
(file)
--- a/
maintenance/cleanupUploadStash.php
+++ b/
maintenance/cleanupUploadStash.php
@@
-38,6
+38,7
@@
class UploadStashCleanup extends Maintenance {
public function __construct() {
parent::__construct();
$this->mDescription = "Clean up abandoned files in temporary uploaded file stash";
public function __construct() {
parent::__construct();
$this->mDescription = "Clean up abandoned files in temporary uploaded file stash";
+ $this->setBatchSize( 50 );
}
public function execute() {
}
public function execute() {
@@
-97,17
+98,22
@@
class UploadStashCleanup extends Maintenance {
$iterator = $tempRepo->getBackend()->getFileList( array( 'dir' => $dir, 'adviseStat' => 1 ) );
$this->output( "Deleting old thumbnails...\n" );
$i = 0;
$iterator = $tempRepo->getBackend()->getFileList( array( 'dir' => $dir, 'adviseStat' => 1 ) );
$this->output( "Deleting old thumbnails...\n" );
$i = 0;
+ $batch = array(); // operation batch
foreach ( $iterator as $file ) {
if ( wfTimestamp( TS_UNIX, $tempRepo->getFileTimestamp( "$dir/$file" ) ) < $cutoff ) {
foreach ( $iterator as $file ) {
if ( wfTimestamp( TS_UNIX, $tempRepo->getFileTimestamp( "$dir/$file" ) ) < $cutoff ) {
- $
status = $tempRepo->quickPurge(
"$dir/$file" );
- if (
!$status->isOK()
) {
- $this->
error( print_r( $status->getErrorsArray(), true )
);
- }
- if ( ( ++$i % 100 ) == 0 ) {
+ $
batch[] = array( 'op' => 'delete', 'src' =>
"$dir/$file" );
+ if (
count( $batch ) >= $this->mBatchSize
) {
+ $this->
doOperations( $tempRepo, $batch
);
+ $i += count( $batch );
+ $batch = array();
$this->output( "$i\n" );
}
}
}
$this->output( "$i\n" );
}
}
}
+ if ( count( $batch ) ) {
+ $this->doOperations( $tempRepo, $batch );
+ $i += count( $batch );
+ }
$this->output( "$i done\n" );
// Apparently lots of stash files are not registered in the DB...
$this->output( "$i done\n" );
// Apparently lots of stash files are not registered in the DB...
@@
-118,19
+124,31
@@
class UploadStashCleanup extends Maintenance {
$this->error( "Temp repo is not using the temp container.", 1 ); // die
}
$i = 0;
$this->error( "Temp repo is not using the temp container.", 1 ); // die
}
$i = 0;
+ $batch = array(); // operation batch
foreach ( $iterator as $file ) {
if ( wfTimestamp( TS_UNIX, $tempRepo->getFileTimestamp( "$dir/$file" ) ) < $cutoff ) {
foreach ( $iterator as $file ) {
if ( wfTimestamp( TS_UNIX, $tempRepo->getFileTimestamp( "$dir/$file" ) ) < $cutoff ) {
- $
status = $tempRepo->quickPurge(
"$dir/$file" );
- if (
!$status->isOK()
) {
- $this->
error( print_r( $status->getErrorsArray(), true )
);
- }
- if ( ( ++$i % 100 ) == 0 ) {
+ $
batch[] = array( 'op' => 'delete', 'src' =>
"$dir/$file" );
+ if (
count( $batch ) >= $this->mBatchSize
) {
+ $this->
doOperations( $tempRepo, $batch
);
+ $i += count( $batch );
+ $batch = array();
$this->output( "$i\n" );
}
}
}
$this->output( "$i\n" );
}
}
}
+ if ( count( $batch ) ) {
+ $this->doOperations( $tempRepo, $batch );
+ $i += count( $batch );
+ }
$this->output( "$i done\n" );
}
$this->output( "$i done\n" );
}
+
+ protected function doOperations( FileRepo $tempRepo, array $ops ) {
+ $status = $tempRepo->getBackend()->doQuickOperations( $ops );
+ if ( !$status->isOK() ) {
+ $this->error( print_r( $status->getErrorsArray(), true ) );
+ }
+ }
}
$maintClass = "UploadStashCleanup";
}
$maintClass = "UploadStashCleanup";