move profile folder to application support on osx

this works around the data loss sierra's
icloud drive can cause
This commit is contained in:
Damien Elmes 2016-12-13 13:30:19 +10:00
parent dbbaba67a6
commit 9cab6634c9

View file

@ -69,6 +69,7 @@ class ProfileManager(object):
self.base = os.path.abspath(base)
else:
self.base = self._defaultBase()
self.maybeMigrateFolder()
self.ensureBaseExists()
# load metadata
self.firstRun = self._loadMeta()
@ -95,6 +96,17 @@ issue, please see the documentation for information on running Anki from \
a flash drive.""" % self.base)
raise
# Folder migration
######################################################################
def maybeMigrateFolder(self):
if not isMac:
return
oldBase = os.path.expanduser("~/Documents/Anki")
if not os.path.exists(self.base) and os.path.exists(oldBase):
os.rename(oldBase, self.base)
os.symlink(self.base, oldBase)
# Profile load/save
######################################################################
@ -217,7 +229,7 @@ and no other programs are accessing your profile folders, then try again."""))
loc = QDesktopServices.storageLocation(QDesktopServices.DocumentsLocation)
return os.path.join(loc, "Anki")
elif isMac:
return os.path.expanduser("~/Documents/Anki")
return os.path.expanduser("~/Library/Application Support/Anki2")
else:
# use Documents/Anki on new installs, ~/Anki on existing ones
p = os.path.expanduser("~/Anki")