mirror of
https://github.com/ankitects/anki.git
synced 2025-09-24 16:56:36 -04:00
if media is off, don't upgrade it
This commit is contained in:
parent
53cd0c5b9f
commit
8122c42245
2 changed files with 13 additions and 10 deletions
|
@ -20,6 +20,7 @@ class MediaManager(object):
|
|||
def __init__(self, col, server):
|
||||
self.col = col
|
||||
if server:
|
||||
self._dir = None
|
||||
return
|
||||
# media directory
|
||||
self._dir = re.sub("(?i)\.(anki2)$", ".media", self.col.path)
|
||||
|
|
|
@ -124,16 +124,18 @@ def _upgrade(col, ver):
|
|||
# adding an empty file to a zip makes python's zip code think it's a
|
||||
# folder, so remove any empty files
|
||||
changed = False
|
||||
for f in os.listdir(col.media.dir()):
|
||||
if os.path.isfile(f) and not os.path.getsize(f):
|
||||
os.unlink(f)
|
||||
col.media.db.execute(
|
||||
"delete from log where fname = ?", f)
|
||||
col.media.db.execute(
|
||||
"delete from media where fname = ?", f)
|
||||
changed = True
|
||||
if changed:
|
||||
col.media.db.commit()
|
||||
dir = col.media.dir()
|
||||
if dir:
|
||||
for f in os.listdir(col.media.dir()):
|
||||
if os.path.isfile(f) and not os.path.getsize(f):
|
||||
os.unlink(f)
|
||||
col.media.db.execute(
|
||||
"delete from log where fname = ?", f)
|
||||
col.media.db.execute(
|
||||
"delete from media where fname = ?", f)
|
||||
changed = True
|
||||
if changed:
|
||||
col.media.db.commit()
|
||||
col.db.execute("update col set ver = 9")
|
||||
if ver < 10:
|
||||
col.db.execute("""
|
||||
|
|
Loading…
Reference in a new issue