r106882 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r106881‎ | r106882 | r106883 >
Date:22:40, 20 December 2011
Author:ben
Status:resolved
Tags:
Comment:
making the hash in the filename part of the container
Modified paths:
  • /trunk/extensions/SwiftMedia/wmf/rewrite.py (modified) (history)

Diff [purge]

Index: trunk/extensions/SwiftMedia/wmf/rewrite.py
@@ -167,18 +167,24 @@
168168 # example:
169169 # http://upload.wikimedia.org/wikipedia/commons/a/aa/000_Finlanda_harta.PNG
170170 # http://upload.wikimedia.org/wikipedia/commons/thumb/a/aa/000_Finlanda_harta.PNG/75px-000_Finlanda_harta.PNG
171 - match = re.match(r'/(.*?)/(.*?)/(.*)', req.path)
 171+ match = re.match(r'/(?P<proj>.*?)/(?P<lang>.*?)/(?P<thumb>thumb/)?(?P<shard>./../)?(?P<path>.*)', req.path)
172172 if match:
173173 # Our target URL is as follows (example):
174 - # https://alsted.wikimedia.org:8080/v1/AUTH_6790933748e741268babd69804c6298b/wikipedia-en/2/25/Machinesmith.png
 174+ # https://alsted.wikimedia.org:8080/v1/AUTH_6790933748e741268babd69804c6298b/wikipedia-en-25/Machinesmith.png
 175+ # http://msfe/v1/AUTH_6790933748e741268babd69804c6298b/wikipedia-commons-aa/000_Finlanda_harta.PNG
 176+ # http://mfse/v1/AUTH_6790933748e741268babd69804c6298b/wikipedia-commons-thumb-aa/000_Finlanda_harta.PNG/75px-000_Finlanda_harta.PNG
175177
176178 # quote slashes in the container name
177 - container = "%s-%s" % (match.group(1), match.group(2)) #02
178 - obj = match.group(3)
 179+ container = "%s-%s" % (match.group('proj'), match.group('lang')) #02
 180+ thumb = match.group('thumb')
 181+ shard = match.group('shard')
 182+ obj = match.group('path')
179183 # include the thumb in the container.
180 - if obj.startswith("thumb/"): #03
 184+ if thumb: #03
181185 container += "-thumb"
182 - obj = obj[len("thumb/"):]
 186+ if shard:
 187+ #add only the 2-digit shard to the container name
 188+ container += "-%s" % shard[2:4]
183189
184190 if not obj:
185191 # don't let them list the container (it's CRAZY huge) #08

Follow-up revisions

RevisionCommit summaryAuthorDate
r106890adding in logic to handle /temp and /archive r106882ben23:22, 20 December 2011

Status & tagging log