Auto-empty trash items older than 30 days by default
- Warning needed on upgrade about this - Controlled by trashAutoEmptyDays hidden pref, with 0 disabling the functionality
This commit is contained in:
parent
9dad2c6048
commit
0b83c8c166
5 changed files with 28 additions and 5 deletions
|
@ -417,6 +417,15 @@ var ZoteroPane = new function()
|
||||||
// Focus the quicksearch on pane open
|
// Focus the quicksearch on pane open
|
||||||
setTimeout("document.getElementById('zotero-tb-search').inputField.select();", 1);
|
setTimeout("document.getElementById('zotero-tb-search').inputField.select();", 1);
|
||||||
|
|
||||||
|
// Auto-empty trashed items older than a certain number of days
|
||||||
|
var days = Zotero.Prefs.get('trashAutoEmptyDays');
|
||||||
|
if (days) {
|
||||||
|
var d = new Date();
|
||||||
|
var deleted = Zotero.Items.emptyTrash(days);
|
||||||
|
var d2 = new Date();
|
||||||
|
Zotero.debug("Emptied old items from trash in " + (d2 - d) + " ms");
|
||||||
|
}
|
||||||
|
|
||||||
var d = new Date();
|
var d = new Date();
|
||||||
Zotero.purgeDataObjects();
|
Zotero.purgeDataObjects();
|
||||||
var d2 = new Date();
|
var d2 = new Date();
|
||||||
|
|
|
@ -130,8 +130,11 @@ Zotero.Items = new function() {
|
||||||
* Zotero.Item objects
|
* Zotero.Item objects
|
||||||
* @return {Zotero.Item[]|Integer[]}
|
* @return {Zotero.Item[]|Integer[]}
|
||||||
*/
|
*/
|
||||||
this.getDeleted = function (asIDs) {
|
this.getDeleted = function (asIDs, days) {
|
||||||
var sql = "SELECT itemID FROM deletedItems";
|
var sql = "SELECT itemID FROM deletedItems";
|
||||||
|
if (days) {
|
||||||
|
sql += " WHERE dateDeleted<=DATE('NOW', '-" + parseInt(days) + " DAYS')";
|
||||||
|
}
|
||||||
var ids = Zotero.DB.columnQuery(sql);
|
var ids = Zotero.DB.columnQuery(sql);
|
||||||
if (asIDs) {
|
if (asIDs) {
|
||||||
return ids;
|
return ids;
|
||||||
|
@ -397,14 +400,18 @@ Zotero.Items = new function() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
this.emptyTrash = function () {
|
/**
|
||||||
|
* @param {Integer} days Only delete items deleted more than this many days ago
|
||||||
|
*/
|
||||||
|
this.emptyTrash = function (days) {
|
||||||
Zotero.DB.beginTransaction();
|
Zotero.DB.beginTransaction();
|
||||||
var deletedIDs = this.getDeleted(true);
|
var deletedIDs = this.getDeleted(true, days);
|
||||||
if (deletedIDs) {
|
if (deletedIDs) {
|
||||||
this.erase(deletedIDs);
|
this.erase(deletedIDs);
|
||||||
|
Zotero.Notifier.trigger('refresh', 'collection', 0);
|
||||||
}
|
}
|
||||||
Zotero.Notifier.trigger('refresh', 'collection', 0);
|
|
||||||
Zotero.DB.commitTransaction();
|
Zotero.DB.commitTransaction();
|
||||||
|
return deletedIDs ? deletedIDs.length : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -2906,6 +2906,11 @@ Zotero.Schema = new function(){
|
||||||
Zotero.DB.query("UPDATE savedSearchConditions SET condition='libraryCatalog' WHERE condition='repository'");
|
Zotero.DB.query("UPDATE savedSearchConditions SET condition='libraryCatalog' WHERE condition='repository'");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 2.1
|
||||||
|
if (i==74) {
|
||||||
|
Zotero.DB.query("CREATE INDEX deletedItems_dateDeleted ON deletedItems(dateDeleted)");
|
||||||
|
}
|
||||||
|
|
||||||
Zotero.wait();
|
Zotero.wait();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -35,6 +35,7 @@ pref("extensions.zotero.launchNonNativeFiles", false);
|
||||||
pref("extensions.zotero.sortNotesChronologically", false);
|
pref("extensions.zotero.sortNotesChronologically", false);
|
||||||
pref("extensions.zotero.sortAttachmentsChronologically", false);
|
pref("extensions.zotero.sortAttachmentsChronologically", false);
|
||||||
pref("extensions.zotero.showTrashWhenEmpty", true);
|
pref("extensions.zotero.showTrashWhenEmpty", true);
|
||||||
|
pref("extensions.zotero.trashAutoEmptyDays", 30);
|
||||||
pref("extensions.zotero.viewOnDoubleClick", true);
|
pref("extensions.zotero.viewOnDoubleClick", true);
|
||||||
|
|
||||||
pref("extensions.zotero.groups.copyChildLinks", true);
|
pref("extensions.zotero.groups.copyChildLinks", true);
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
-- 73
|
-- 74
|
||||||
|
|
||||||
-- Copyright (c) 2009 Center for History and New Media
|
-- Copyright (c) 2009 Center for History and New Media
|
||||||
-- George Mason University, Fairfax, Virginia, USA
|
-- George Mason University, Fairfax, Virginia, USA
|
||||||
|
@ -212,6 +212,7 @@ CREATE TABLE deletedItems (
|
||||||
itemID INTEGER PRIMARY KEY,
|
itemID INTEGER PRIMARY KEY,
|
||||||
dateDeleted DEFAULT CURRENT_TIMESTAMP NOT NULL
|
dateDeleted DEFAULT CURRENT_TIMESTAMP NOT NULL
|
||||||
);
|
);
|
||||||
|
CREATE INDEX deletedItems_dateDeleted ON deletedItems(dateDeleted);
|
||||||
|
|
||||||
CREATE TABLE relations (
|
CREATE TABLE relations (
|
||||||
libraryID INT NOT NULL,
|
libraryID INT NOT NULL,
|
||||||
|
|
Loading…
Reference in a new issue