if media is off, don't upgrade it

This commit is contained in:
Damien Elmes 2012-05-29 08:29:18 +09:00
parent 53cd0c5b9f
commit 8122c42245
2 changed files with 13 additions and 10 deletions

View file

@ -20,6 +20,7 @@ class MediaManager(object):
def __init__(self, col, server): def __init__(self, col, server):
self.col = col self.col = col
if server: if server:
self._dir = None
return return
# media directory # media directory
self._dir = re.sub("(?i)\.(anki2)$", ".media", self.col.path) self._dir = re.sub("(?i)\.(anki2)$", ".media", self.col.path)

View file

@ -124,6 +124,8 @@ def _upgrade(col, ver):
# adding an empty file to a zip makes python's zip code think it's a # adding an empty file to a zip makes python's zip code think it's a
# folder, so remove any empty files # folder, so remove any empty files
changed = False changed = False
dir = col.media.dir()
if dir:
for f in os.listdir(col.media.dir()): for f in os.listdir(col.media.dir()):
if os.path.isfile(f) and not os.path.getsize(f): if os.path.isfile(f) and not os.path.getsize(f):
os.unlink(f) os.unlink(f)