mirror of
https://github.com/zotero/zotero.git
synced 2026-10-10 03:28:10 +00:00
Store vacuum.lastTime as seconds, not milliseconds
Also drop the default pref, since this is just internal state
This commit is contained in:
parent
f20eb5b566
commit
56ef61e45b
3 changed files with 5 additions and 5 deletions
|
|
@ -951,8 +951,9 @@ Zotero.DBConnection.prototype.vacuum = async function ({ force } = {}) {
|
|||
// Check time threshold
|
||||
let lastVacuum = Zotero.Prefs.get('vacuum.lastTime') || 0;
|
||||
let intervalDays = Zotero.Prefs.get('vacuum.interval') || 14;
|
||||
let intervalMs = intervalDays * 24 * 60 * 60 * 1000;
|
||||
if ((Date.now() - lastVacuum) < intervalMs) {
|
||||
let intervalSeconds = intervalDays * 24 * 60 * 60;
|
||||
let nowSeconds = Math.floor(Date.now() / 1000);
|
||||
if ((nowSeconds - lastVacuum) < intervalSeconds) {
|
||||
Zotero.debug("Database was vacuumed recently -- skipping");
|
||||
return false;
|
||||
}
|
||||
|
|
@ -1021,7 +1022,7 @@ Zotero.DBConnection.prototype.vacuum = async function ({ force } = {}) {
|
|||
// Atomic swap
|
||||
await IOUtils.move(tmpFile, this._dbPath);
|
||||
|
||||
Zotero.Prefs.set('vacuum.lastTime', Date.now());
|
||||
Zotero.Prefs.set('vacuum.lastTime', Math.floor(Date.now() / 1000));
|
||||
Zotero.debug("Vacuumed database in " + (new Date() - t) + " ms");
|
||||
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -68,7 +68,6 @@ pref("extensions.zotero.feeds.defaultCleanupUnreadAfter", 30);
|
|||
pref("extensions.zotero.backup.numBackups", 2);
|
||||
pref("extensions.zotero.backup.interval", 1440);
|
||||
|
||||
pref("extensions.zotero.vacuum.lastTime", 0);
|
||||
pref("extensions.zotero.vacuum.interval", 14); // days
|
||||
pref("extensions.zotero.vacuum.freelistThreshold", 10); // percentage of free pages to trigger
|
||||
|
||||
|
|
|
|||
|
|
@ -450,7 +450,7 @@ describe("Zotero.DB", function () {
|
|||
});
|
||||
|
||||
it("should skip vacuum when recently vacuumed", async function () {
|
||||
Zotero.Prefs.set('vacuum.lastTime', Date.now());
|
||||
Zotero.Prefs.set('vacuum.lastTime', Math.floor(Date.now() / 1000));
|
||||
let result = await Zotero.DB.vacuum();
|
||||
assert.isFalse(result);
|
||||
Zotero.Prefs.clear('vacuum.lastTime');
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue