r106890 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r106889‎ | r106890 | r106891 >
Date:23:22, 20 December 2011
Author:ben
Status:resolved (Comments)
Tags:
Comment:
adding in logic to handle /temp and /archive r106882
Modified paths:
  • /trunk/extensions/SwiftMedia/wmf/rewrite.py (modified) (history)

Diff [purge]

Index: trunk/extensions/SwiftMedia/wmf/rewrite.py
@@ -168,7 +168,7 @@
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
171171 # http://upload.wikimedia.org/wikipedia/commons/thumb/archive/b/b6/20101108115418!Gilbert_Stuart_Williamstown_Portrait_of_George_Washington.jpg/100px-Gilbert_Stuart_Williamstown_Portrait_of_George_Washington.jpg
172 - match = re.match(r'/(?P<proj>.*?)/(?P<lang>.*?)/(?P<thumb>thumb/)?(?P<shard>./../)?(?P<path>.*)', req.path)
 172+ match = re.match(r'/(?P<proj>.*?)/(?P<lang>.*?)/(?P<thumb>thumb/)?(?P<archive>(temp|archive)/)?(?P<shard>./../)?(?P<path>.*)', req.path)
173173 if match:
174174 # Our target URL is as follows (example):
175175 # https://alsted.wikimedia.org:8080/v1/AUTH_6790933748e741268babd69804c6298b/wikipedia-en-25/Machinesmith.png
@@ -180,12 +180,16 @@
181181 thumb = match.group('thumb')
182182 shard = match.group('shard')
183183 obj = match.group('path')
 184+ arch = match.group('archive')
184185 # include the thumb in the container.
185186 if thumb: #03
186187 container += "-thumb"
187188 if shard:
188189 #add only the 2-digit shard to the container name
189190 container += "-%s" % shard[2:4]
 191+ if arch:
 192+ # for urls that go /wiki/thumb/archive/a/ab/path, the container is wiki-thumb-ab and the obj is archive/path
 193+ obj = "%s%s" % (arch, obj)
190194
191195 if not obj:
192196 # don't let them list the container (it's CRAZY huge) #08

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r106882making the hash in the filename part of the containerben22:40, 20 December 2011

Comments

#Comment by Aaron Schulz (talk | contribs)   01:08, 24 December 2011

Calling the archive/temp pattern <archive> is a bit misleading, maybe called it <subdir> or <archOrTemp>.

Also, I think (?P<shard>./../) should be optional. All of our local repo paths have this many hash levels.

#Comment by Aaron Schulz (talk | contribs)   00:22, 11 January 2012

I meant "should not be optional"...gah

Status & tagging log