mirror of
https://github.com/ankitects/anki.git
synced 2025-09-19 14:32:22 -04:00
prevent profiles from getting out of sync when rename fails
If there is an error in renaming the folder, don't write the new profile name to the database.
This commit is contained in:
parent
a261f15269
commit
0c937074eb
1 changed files with 16 additions and 2 deletions
|
@ -164,8 +164,22 @@ a flash drive.""" % self.base)
|
||||||
self.db.execute("update profiles set name = ? where name = ?",
|
self.db.execute("update profiles set name = ? where name = ?",
|
||||||
name.encode("utf8"), oldName.encode("utf-8"))
|
name.encode("utf8"), oldName.encode("utf-8"))
|
||||||
# rename folder
|
# rename folder
|
||||||
os.rename(oldFolder, newFolder)
|
try:
|
||||||
self.db.commit()
|
os.rename(oldFolder, newFolder)
|
||||||
|
except WindowsError as e:
|
||||||
|
self.db.rollback()
|
||||||
|
if "Access is denied" in e:
|
||||||
|
showWarning(_("""\
|
||||||
|
Anki could not rename your profile because it could not rename the profile \
|
||||||
|
folder on disk. Please ensure you have permission to write to Documents/Anki \
|
||||||
|
and no other programs are accessing your profile folders, then try again."""))
|
||||||
|
else:
|
||||||
|
raise
|
||||||
|
except:
|
||||||
|
self.db.rollback()
|
||||||
|
raise
|
||||||
|
else:
|
||||||
|
self.db.commit()
|
||||||
|
|
||||||
# Folder handling
|
# Folder handling
|
||||||
######################################################################
|
######################################################################
|
||||||
|
|
Loading…
Reference in a new issue