mirror of
https://github.com/ankitects/anki.git
synced 2025-09-20 06:52:21 -04:00
fix backup on win32
This commit is contained in:
parent
8750b9bbbb
commit
2aecbffafe
1 changed files with 3 additions and 9 deletions
12
anki/deck.py
12
anki/deck.py
|
@ -2184,23 +2184,17 @@ where interval < 1""")
|
|||
_setUTCOffset = staticmethod(_setUTCOffset)
|
||||
|
||||
def backup(modified, path):
|
||||
try:
|
||||
os.makedirs(backupDir)
|
||||
except OSError:
|
||||
pass
|
||||
# need a non-unicode path
|
||||
path = path.encode(sys.getfilesystemencoding())
|
||||
bdir = backupDir.encode(sys.getfilesystemencoding())
|
||||
def backupName(path, num):
|
||||
path = os.path.abspath(path)
|
||||
path = path.replace("\\", "!")
|
||||
path = path.replace("/", "!")
|
||||
path = path.replace(":", "")
|
||||
path = os.path.join(bdir, path)
|
||||
path = os.path.join(backupDir, path)
|
||||
path = re.sub("\.anki$", ".backup-%d.anki" % num, path)
|
||||
return path
|
||||
if not os.path.exists(bdir):
|
||||
os.makedirs(bdir)
|
||||
if not os.path.exists(backupDir):
|
||||
os.makedirs(backupDir)
|
||||
# if the mod time is identical, don't make a new backup
|
||||
firstBack = backupName(path, 0)
|
||||
if os.path.exists(firstBack):
|
||||
|
|
Loading…
Reference in a new issue