Brion VIBBER has uploaded a new change for review. (
https://gerrit.wikimedia.org/r/343771 )
Change subject: Remove obsoleted maint scripts in favor of requeueTranscodes.php
......................................................................
Remove obsoleted maint scripts in favor of requeueTranscodes.php
The new requeueTranscodes.php handles several cases better:
* has a --throttle option to avoid flooding queues
* handles cases where transcode table wasn't filled out right
* more flexible config options on one script
* should handle multiple overlapping cases better
Change-Id: I321d4869ac8ea187c2bbf0fbfc0ce0ad3a540630
---
D maintenance/cleanupTranscodes.php
D maintenance/moveTranscoded.php
D maintenance/resetTranscodes.php
D maintenance/retryTranscodes.php
4 files changed, 0 insertions(+), 197 deletions(-)
git pull
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/TimedMediaHandler
refs/changes/71/343771/1
diff --git a/maintenance/cleanupTranscodes.php
b/maintenance/cleanupTranscodes.php
deleted file mode 100644
index 6bcf216..0000000
--- a/maintenance/cleanupTranscodes.php
+++ /dev/null
@@ -1,47 +0,0 @@
-<?php
-/**
- * cleanup transcodes no longer defined in $wgEnabledTranscodeSet
- *
- */
-$IP = getenv( 'MW_INSTALL_PATH' );
-if ( $IP === false ) {
- $IP = __DIR__ . '/../../..';
-}
-require_once "$IP/maintenance/Maintenance.php";
-
-class CleanupTranscodes extends Maintenance {
-
- public function __construct() {
- parent::__construct();
- $this->addOption( "key", "remove all transcodes for given key",
false, true );
- $this->addOption( "all", "remove all transcodes", false, false
);
- $this->mDescription = "cleanup transcodes left over after
changing encoding profiles.";
- }
- public function execute() {
- global $wgEnabledTranscodeSet, $wgEnabledAudioTranscodeSet;
- $transcodeSet = array_merge( $wgEnabledTranscodeSet,
$wgEnabledAudioTranscodeSet );
-
- if ( $this->hasOption( "all" ) ) {
- $where = [];
- } elseif ( $this->hasOption( "key" ) ) {
- $where = [ 'transcode_key' => $this->getOption( 'key'
) ];
- } else {
- $where = 'transcode_key NOT IN ("'. implode( '", "',
$transcodeSet ).'")';
- }
- $this->output( "Cleanup transcodes:\n" );
- $dbr = wfGetDB( DB_SLAVE );
- $res = $dbr->select( 'transcode', '*', $where, __METHOD__ );
- foreach ( $res as $row ) {
- $this->output(
- 'remove: '. $row->transcode_image_name . ' ' .
$row->transcode_key . "\n"
- );
- $title = Title::newFromText(
$row->transcode_image_name, NS_FILE );
- $file = wfLocalFile( $title );
- WebVideoTranscode::removeTranscodes( $file,
$row->transcode_key );
- }
- $this->output( "Finished!\n" );
- }
-}
-
-$maintClass = 'CleanupTranscodes'; // Tells it to run the class
-require_once RUN_MAINTENANCE_IF_MAIN;
diff --git a/maintenance/moveTranscoded.php b/maintenance/moveTranscoded.php
deleted file mode 100644
index 2434dd4..0000000
--- a/maintenance/moveTranscoded.php
+++ /dev/null
@@ -1,55 +0,0 @@
-<?php
-/**
- * move transcoded files from thumb to transcoded container
- *
- */
-$IP = getenv( 'MW_INSTALL_PATH' );
-if ( $IP === false ) {
- $IP = __DIR__ . '/../../..';
-}
-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() {
-
- $this->output( "Move transcoded files:\n" );
- $dbr = wfGetDB( DB_SLAVE );
- $res = $dbr->select( 'transcode', '*', [], __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;
diff --git a/maintenance/resetTranscodes.php b/maintenance/resetTranscodes.php
deleted file mode 100644
index ffb2605..0000000
--- a/maintenance/resetTranscodes.php
+++ /dev/null
@@ -1,40 +0,0 @@
-<?php
-/**
- * reset stalled transcodes
- *
- */
-$IP = getenv( 'MW_INSTALL_PATH' );
-if ( $IP === false ) {
- $IP = __DIR__ . '/../../..';
-}
-require_once "$IP/maintenance/Maintenance.php";
-
-class ResetTranscodes extends Maintenance {
-
- public function __construct() {
- parent::__construct();
- $this->mDescription = "Reset stalled transcodes, that are no
longer in the job queue.";
- }
- public function execute() {
- $where = [
- "transcode_time_startwork" => null,
- "transcode_time_error" => null
- ];
- $dbr = wfGetDB( DB_SLAVE );
- $res = $dbr->select( 'transcode', '*', $where, __METHOD__ );
- foreach ( $res as $row ) {
- $title = Title::newFromText(
$row->transcode_image_name, NS_FILE );
- // re-insert WebVideoTranscodeJob,
- // will only be added if not in queue
- // due to deduplication
- $job = new WebVideoTranscodeJob( $title, [
- 'transcodeMode' => 'derivative',
- 'transcodeKey' => $row->transcode_key,
- ] );
- JobQueueGroup::singleton()->push( $job );
- }
- }
-}
-
-$maintClass = 'ResetTranscodes'; // Tells it to run the class
-require_once ( RUN_MAINTENANCE_IF_MAIN );
diff --git a/maintenance/retryTranscodes.php b/maintenance/retryTranscodes.php
deleted file mode 100644
index 5360c2a..0000000
--- a/maintenance/retryTranscodes.php
+++ /dev/null
@@ -1,55 +0,0 @@
-<?php
-/**
- * Retry transcodes for a given key or error.
- * This script can be used after updating/fixing
- * the encoding pipeline to rerun transcodes
- * that are known to work now.
- *
- */
-$IP = getenv( 'MW_INSTALL_PATH' );
-if ( $IP === false ) {
- $IP = __DIR__ . '/../../..';
-}
-require_once "$IP/maintenance/Maintenance.php";
-
-class RetryTranscodes extends Maintenance {
-
- public function __construct() {
- parent::__construct();
- $this->addOption( "key", "retry all failed transcodes for given
key", false, true );
- $this->addOption( "error", "retry all failed transcodes
matching error substring", false, true );
- $this->mDescription = "retry transcodes for given key or error";
- }
- public function execute() {
- if ( !$this->hasOption( "error" ) && !$this->hasOption( "key" )
) {
- $this->output( "You have to provide --key and/or
--error\n" );
- return;
- }
- $dbw = wfGetDB( DB_MASTER );
- $cond = [];
- $cond[] = 'transcode_time_error IS NOT NULL';
- if ( $this->hasOption( "key" ) ) {
- $cond['transcode_key'] = $this->getOption( 'key' );
- }
- if ( $this->hasOption( "error" ) ) {
- $cond[] = "transcode_error " . $dbw->buildLike(
$dbw->anyString(),
- $this->getOption( 'error' ), $dbw->anyString()
);
- }
- do {
- $res = $dbw->select( 'transcode', 'transcode_id',
- $cond, __METHOD__, [ 'LIMIT' => 100 ] );
- $ids = [];
- foreach ( $res as $row ) {
- $ids[] = $row->transcode_id;
- }
- if ( $ids ) {
- $dbw->delete( 'transcode',
- [ 'transcode_id' => $ids ], __METHOD__
);
- wfWaitForSlaves();
- }
- } while ( $ids );
- }
-}
-
-$maintClass = 'RetryTranscodes'; // Tells it to run the class
-require_once ( RUN_MAINTENANCE_IF_MAIN );
--
To view, visit https://gerrit.wikimedia.org/r/343771
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I321d4869ac8ea187c2bbf0fbfc0ce0ad3a540630
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/TimedMediaHandler
Gerrit-Branch: master
Gerrit-Owner: Brion VIBBER <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits