mirror of
https://github.com/zotero/zotero.git
synced 2026-10-06 02:50:03 +00:00
Don't clear the saved session if startup fails
Zotero.Session.save() runs from a quit-application-granted observer
registered before the database checks, but session.json is only read
after them, so a startup error -- an incompatible database from a newer
version, say -- meant that quitting overwrote the file with an empty
state and all open tabs were lost.
https://forums.zotero.org/discussion/133542/
(cherry picked from commit 9e28eb0d39)
This commit is contained in:
parent
ec128e020a
commit
7fe1162405
1 changed files with 7 additions and 0 deletions
|
|
@ -30,6 +30,7 @@ Zotero.Session = new function () {
|
|||
let _state = {
|
||||
windows: []
|
||||
};
|
||||
let _initialized = false;
|
||||
|
||||
Zotero.defineProperty(this, 'state', {
|
||||
get: () => {
|
||||
|
|
@ -48,6 +49,7 @@ Zotero.Session = new function () {
|
|||
Zotero.logError(e);
|
||||
}
|
||||
}
|
||||
_initialized = true;
|
||||
};
|
||||
|
||||
this.setLastClosedZoteroPaneState = function (state) {
|
||||
|
|
@ -59,6 +61,11 @@ Zotero.Session = new function () {
|
|||
}, DEBOUNCED_SAVING_DELAY);
|
||||
|
||||
this.save = async function () {
|
||||
// Don't overwrite the saved session if startup failed before the session was loaded
|
||||
if (!_initialized) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
// Saving is triggered in `zotero.js` when a quit event is received,
|
||||
// though if it was triggered by closing a window, ZoteroPane might
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue