summaryrefslogtreecommitdiff
path: root/extensions/TimedMediaHandler/maintenance/moveTranscoded.php
diff options
context:
space:
mode:
Diffstat (limited to 'extensions/TimedMediaHandler/maintenance/moveTranscoded.php')
-rw-r--r--extensions/TimedMediaHandler/maintenance/moveTranscoded.php56
1 files changed, 56 insertions, 0 deletions
diff --git a/extensions/TimedMediaHandler/maintenance/moveTranscoded.php b/extensions/TimedMediaHandler/maintenance/moveTranscoded.php
new file mode 100644
index 00000000..1ff6717c
--- /dev/null
+++ b/extensions/TimedMediaHandler/maintenance/moveTranscoded.php
@@ -0,0 +1,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 );