Delete all extra backup sessions if MAX is reached
This commit is contained in:
parent
35788b54ba
commit
5671eb4782
2 changed files with 11 additions and 3 deletions
|
@ -89,11 +89,17 @@
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var oldestSession = sessions.sort(function (s1, s2) {
|
// Prepare an array containing all the ids of the sessions to be deleted.
|
||||||
|
var sessionIdsToDelete = sessions.sort(function (s1, s2) {
|
||||||
return s1.startDate - s2.startDate;
|
return s1.startDate - s2.startDate;
|
||||||
})[0].id;
|
}).map(function (s) {
|
||||||
|
return s.id;
|
||||||
|
}).slice(0, sessions.length - MAX_SESSIONS);
|
||||||
|
|
||||||
return this.deleteSession(oldestSession);
|
// Delete all the extra sessions.
|
||||||
|
return Q.all(sessionIdsToDelete.map(function (id) {
|
||||||
|
return this.deleteSession(id);
|
||||||
|
}.bind(this)));
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,6 +30,8 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
ns.BeforeUnloadService.prototype.onBeforeUnload = function (evt) {
|
ns.BeforeUnloadService.prototype.onBeforeUnload = function (evt) {
|
||||||
|
// Attempt one last backup. Some of it may fail due to the asynchronous
|
||||||
|
// nature of IndexedDB.
|
||||||
pskl.app.backupService.backup();
|
pskl.app.backupService.backup();
|
||||||
if (pskl.app.savedStatusService.isDirty()) {
|
if (pskl.app.savedStatusService.isDirty()) {
|
||||||
var confirmationMessage = 'Your current sprite has unsaved changes. Are you sure you want to quit?';
|
var confirmationMessage = 'Your current sprite has unsaved changes. Are you sure you want to quit?';
|
||||||
|
|
Loading…
Reference in a new issue