* @ingroup Maintenance
*/
-require_once( __DIR__ . '/Maintenance.php' );
+require_once __DIR__ . '/Maintenance.php';
/**
* Maintenance script to remove old or broken uploads from temporary uploaded
try {
$stash->getFile( $key, true );
$stash->removeFileNoAuth( $key );
- } catch ( UploadStashBadPathException $ex ) {
- $this->output( "Failed removing stashed upload with key: $key\n" );
- } catch ( UploadStashZeroLengthFileException $ex ) {
- $this->output( "Failed removing stashed upload with key: $key\n" );
+ } catch ( UploadStashException $ex ) {
+ $type = get_class( $ex );
+ $this->output( "Failed removing stashed upload with key: $key ($type)\n" );
}
if ( $i % 100 == 0 ) {
$this->output( "$i\n" );
// Apparently lots of stash files are not registered in the DB...
$dir = $tempRepo->getZonePath( 'public' );
- $iterator = $tempRepo->getBackend()->getFileList( array( 'dir' => $dir ) );
+ $iterator = $tempRepo->getBackend()->getFileList( array( 'dir' => $dir, 'adviseStat' => 1 ) );
$this->output( "Deleting orphaned temp files...\n" );
if ( strpos( $dir, '/local-temp' ) === false ) { // sanity check
$this->error( "Temp repo is not using the temp container.", 1 ); // die
$i = 0;
foreach ( $iterator as $file ) {
// Absolute sanity check for stashed files and file segments
- if ( !preg_match( '#(^\d{14}!|\.\d+\.\w+\.\d+$)#', basename( $file ) ) ) {
+ $base = basename( $file );
+ // @TODO: why are there thumbnails stored in here?
+ if ( !preg_match( '#(^\d{14}!|\.\d+\.\w+\.\d+$|-\w{12}\.\w{6}\.\d+\.)#', $base ) ) {
$this->output( "Skipped non-stash $file\n" );
continue;
}
}
$maintClass = "UploadStashCleanup";
-require_once( RUN_MAINTENANCE_IF_MAIN );
+require_once RUN_MAINTENANCE_IF_MAIN;