mirror of
https://github.com/ankitects/anki.git
synced 2025-12-30 23:32:57 -05:00
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:
parent
dbbaba67a6
commit
9cab6634c9
1 changed files with 13 additions and 1 deletions
|
|
@ -69,6 +69,7 @@ class ProfileManager(object):
|
||||||
self.base = os.path.abspath(base)
|
self.base = os.path.abspath(base)
|
||||||
else:
|
else:
|
||||||
self.base = self._defaultBase()
|
self.base = self._defaultBase()
|
||||||
|
self.maybeMigrateFolder()
|
||||||
self.ensureBaseExists()
|
self.ensureBaseExists()
|
||||||
# load metadata
|
# load metadata
|
||||||
self.firstRun = self._loadMeta()
|
self.firstRun = self._loadMeta()
|
||||||
|
|
@ -95,6 +96,17 @@ issue, please see the documentation for information on running Anki from \
|
||||||
a flash drive.""" % self.base)
|
a flash drive.""" % self.base)
|
||||||
raise
|
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
|
# Profile load/save
|
||||||
######################################################################
|
######################################################################
|
||||||
|
|
||||||
|
|
@ -217,7 +229,7 @@ and no other programs are accessing your profile folders, then try again."""))
|
||||||
loc = QDesktopServices.storageLocation(QDesktopServices.DocumentsLocation)
|
loc = QDesktopServices.storageLocation(QDesktopServices.DocumentsLocation)
|
||||||
return os.path.join(loc, "Anki")
|
return os.path.join(loc, "Anki")
|
||||||
elif isMac:
|
elif isMac:
|
||||||
return os.path.expanduser("~/Documents/Anki")
|
return os.path.expanduser("~/Library/Application Support/Anki2")
|
||||||
else:
|
else:
|
||||||
# use Documents/Anki on new installs, ~/Anki on existing ones
|
# use Documents/Anki on new installs, ~/Anki on existing ones
|
||||||
p = os.path.expanduser("~/Anki")
|
p = os.path.expanduser("~/Anki")
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue