blob: 1ff6717cf369a32853b3fc956283eb71a0ad0c99 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
<?php
/**
* move transcoded files from thumb to transcoded container
*
*/
$IP = getenv( 'MW_INSTALL_PATH' );
if ( $IP === false ) {
$IP = dirname( __FILE__ ) . '/../../..';
}
require_once( "$IP/maintenance/Maintenance.php" );
class MoveTranscoded extends Maintenance {
public function __construct() {
parent::__construct();
$this->mDescription = "move transcoded files from thumb to transcoded container.";
}
public function execute() {
global $wgEnabledTranscodeSet;
$this->output( "Move transcoded files:\n" );
$dbr = wfGetDB( DB_SLAVE );
$res = $dbr->select( 'transcode', '*', array(), __METHOD__ );
foreach ( $res as $row ) {
$title = Title::newFromText( $row->transcode_image_name, NS_FILE );
$file = wfLocalFile( $title );
if ( !$file ) {
continue;
}
$oldPath = $file->getThumbPath( $file->getName() . '.' . $row->transcode_key );
$newPath = WebVideoTranscode::getDerivativeFilePath( $file, $row->transcode_key );
if ($oldPath != $newPath) {
if( $file->repo->fileExists( $oldPath ) ){
if( $file->repo->fileExists( $newPath ) ){
$res = $file->repo->quickPurge( $oldPath );
if( !$res ){
wfDebug( "Could not delete file $oldPath\n" );
} else {
$this->output( "deleted $oldPath, exists in transcoded container\n" );
}
} else {
$this->output( " $oldPath => $newPath\n" );
$file->repo->quickImport( $oldPath, $newPath );
$file->repo->quickPurge( $oldPath );
}
}
}
}
$this->output( "Finished!\n" );
}
}
$maintClass = 'MoveTranscoded'; // Tells it to run the class
require_once( RUN_MAINTENANCE_IF_MAIN );
|