mirror of
https://github.com/ankitects/anki.git
synced 2025-09-21 07:22:23 -04:00
allow changing case of profile name on Windows
This commit is contained in:
parent
ebcab2122d
commit
a2eb5a09c3
1 changed files with 18 additions and 3 deletions
|
@ -140,9 +140,24 @@ documentation for information on using a flash drive.""")
|
|||
self.name = name
|
||||
newFolder = self.profileFolder(create=False)
|
||||
if os.path.exists(newFolder):
|
||||
showWarning(_("Folder already exists."))
|
||||
self.name = oldName
|
||||
return
|
||||
if (oldFolder != newFolder) and (
|
||||
oldFolder.lower() == newFolder.lower()):
|
||||
# OS is telling us the folder exists because it does not take
|
||||
# case into account; use a temporary folder location
|
||||
midFolder = ''.join([oldFolder, '-temp'])
|
||||
if not os.path.exists(midFolder):
|
||||
os.rename(oldFolder, midFolder)
|
||||
oldFolder = midFolder
|
||||
else:
|
||||
showWarning(_("Please remove the folder %s and try again.")
|
||||
% midFolder)
|
||||
self.name = oldName
|
||||
return
|
||||
else:
|
||||
showWarning(_("Folder already exists."))
|
||||
self.name = oldName
|
||||
return
|
||||
|
||||
# update name
|
||||
self.db.execute("update profiles set name = ? where name = ?",
|
||||
name.encode("utf8"), oldName.encode("utf-8"))
|
||||
|
|
Loading…
Reference in a new issue