mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 22:12:21 -04:00
check a profile exists every time
if something went wrong between pm.meta() and .ensureProfile() in the past, it would lead to an inability to start Anki due to the a lack of any profiles https://anki.tenderapp.com/discussions/ankidesktop/32972-linux-upgrade-problems-20-219
This commit is contained in:
parent
5c03653f3f
commit
09651be9e7
2 changed files with 13 additions and 11 deletions
|
@ -349,9 +349,6 @@ environment points to a valid, writable folder.""")
|
||||||
QMessageBox.critical(None, "Error", "Your video driver is incompatible. Please start Anki again, and Anki will switch to a slower, more compatible mode.")
|
QMessageBox.critical(None, "Error", "Your video driver is incompatible. Please start Anki again, and Anki will switch to a slower, more compatible mode.")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
# remaining pm init
|
|
||||||
pm.ensureProfile()
|
|
||||||
|
|
||||||
# load the main window
|
# load the main window
|
||||||
import aqt.main
|
import aqt.main
|
||||||
mw = aqt.main.AnkiQt(app, pm, opts, args)
|
mw = aqt.main.AnkiQt(app, pm, opts, args)
|
||||||
|
|
|
@ -126,9 +126,15 @@ a flash drive.""" % self.base)
|
||||||
######################################################################
|
######################################################################
|
||||||
|
|
||||||
def profiles(self):
|
def profiles(self):
|
||||||
return sorted(x for x in
|
def names():
|
||||||
self.db.list("select name from profiles")
|
return self.db.list("select name from profiles where name != '_global'")
|
||||||
if x != "_global")
|
|
||||||
|
n = names()
|
||||||
|
if not n:
|
||||||
|
self._ensureProfile()
|
||||||
|
n = names()
|
||||||
|
|
||||||
|
return n
|
||||||
|
|
||||||
def _unpickle(self, data):
|
def _unpickle(self, data):
|
||||||
class Unpickler(pickle.Unpickler):
|
class Unpickler(pickle.Unpickler):
|
||||||
|
@ -338,12 +344,11 @@ create table if not exists profiles
|
||||||
self._setDefaultLang()
|
self._setDefaultLang()
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def ensureProfile(self):
|
def _ensureProfile(self):
|
||||||
"Create a new profile if none exists."
|
"Create a new profile if none exists."
|
||||||
if self.firstRun:
|
self.create(_("User 1"))
|
||||||
self.create(_("User 1"))
|
p = os.path.join(self.base, "README.txt")
|
||||||
p = os.path.join(self.base, "README.txt")
|
open(p, "w", encoding="utf8").write(_("""\
|
||||||
open(p, "w", encoding="utf8").write(_("""\
|
|
||||||
This folder stores all of your Anki data in a single location,
|
This folder stores all of your Anki data in a single location,
|
||||||
to make backups easy. To tell Anki to use a different location,
|
to make backups easy. To tell Anki to use a different location,
|
||||||
please see:
|
please see:
|
||||||
|
|
Loading…
Reference in a new issue