From a76c6a1bcf44249299ddc7b7cfbbf784f0defd0d Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Fri, 13 Jan 2017 21:14:04 +1000 Subject: [PATCH] use 'Library/Application Support' to match 2.0.x --- aqt/profiles.py | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/aqt/profiles.py b/aqt/profiles.py index 1b4c2e6a0..3df73d9ac 100644 --- a/aqt/profiles.py +++ b/aqt/profiles.py @@ -9,6 +9,8 @@ import os import random import pickle +import shutil + import locale import re @@ -68,6 +70,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() @@ -97,6 +100,21 @@ 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): + shutil.move(oldBase, self.base) + + # remove the old symlink if it exists + if os.path.exists(oldBase) and os.path.islink(oldBase): + os.remove(oldBase) + # Profile load/save ###################################################################### @@ -213,7 +231,7 @@ and no other programs are accessing your profile folders, then try again.""")) loc = QStandardPaths.writableLocation(QStandardPaths.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")