Brion VIBBER has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/331985 )

Change subject: Fix length calculation for shortening transcode filenames
......................................................................

Fix length calculation for shortening transcode filenames

Follow-up to I826af75e to include the hash, which wasn't being
counted causing some files to be miscounted as not requiring
shortage. Also made the counting clearer on what it was doing
instead of having a random ' + 12' at the end. ;)

Should fix long Russian filenames that were _just_ the wrong
length to get stored.

Bug: T155248
Change-Id: I2a3765bd594f5c12b838f9c2d7593596c1dd3936
---
M WebVideoTranscode/WebVideoTranscode.php
1 file changed, 4 insertions(+), 3 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/TimedMediaHandler 
refs/changes/85/331985/1

diff --git a/WebVideoTranscode/WebVideoTranscode.php 
b/WebVideoTranscode/WebVideoTranscode.php
index 0ada0c4..eaccdb9 100644
--- a/WebVideoTranscode/WebVideoTranscode.php
+++ b/WebVideoTranscode/WebVideoTranscode.php
@@ -538,8 +538,8 @@
         * Get the name to use as the base name for the transcode.
         *
         * Swift has problems where the url-encoded version of
-        * the path (ie 'filename.ogv/filename.ogv.720p.webm' )
-        * is greater that > 1024 bytes, so shorten in that case.
+        * the path (ie '0/00/filename.ogv/filename.ogv.720p.webm' )
+        * is greater than > 1024 bytes, so shorten in that case.
         *
         * Future versions might respect FileRepo::$abbrvThreshold.
         *
@@ -549,7 +549,8 @@
         */
        public static function getTranscodeFileBaseName( $file, $suffix = '' ) {
                $name = $file->getName();
-               if ( strlen( urlencode( $name ) ) * 2 + 12 > 1024 ) {
+               $length = strlen( urlencode( '0/00/' . $name . '/' . $name . 
'.' . $suffix ) );
+               if ( $length > 1024 ) {
                        return 'transcode' . '.' . $suffix;
                } else {
                        return $name . '.' . $suffix;

-- 
To view, visit https://gerrit.wikimedia.org/r/331985
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I2a3765bd594f5c12b838f9c2d7593596c1dd3936
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/TimedMediaHandler
Gerrit-Branch: master
Gerrit-Owner: Brion VIBBER <br...@wikimedia.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to