Set tag/creator purge flag on removals from items, and run purge on sync
This commit is contained in:
parent
7a195b8388
commit
b76fdd8e43
|
@ -346,7 +346,7 @@ var ZoteroPane = new function()
|
|||
setTimeout("document.getElementById('zotero-tb-search').inputField.select();", 1);
|
||||
|
||||
var d = new Date();
|
||||
Zotero.purgeDataObjects(true);
|
||||
Zotero.purgeDataObjects();
|
||||
var d2 = new Date();
|
||||
Zotero.debug("Purged data tables in " + (d2 - d) + " ms");
|
||||
|
||||
|
|
|
@ -908,11 +908,16 @@ Zotero.Item.prototype.removeCreator = function(orderIndex) {
|
|||
this._loadCreators();
|
||||
}
|
||||
|
||||
if (!this._creators[orderIndex]) {
|
||||
var creator = this.getCreator(orderIndex);
|
||||
if (!creator) {
|
||||
throw ('No creator exists at position ' + orderIndex
|
||||
+ ' in Zotero.Item.removeCreator()');
|
||||
}
|
||||
|
||||
if (creator.ref.countLinkedItems() == 1) {
|
||||
Zotero.Prefs.set('purge.creators', true);
|
||||
}
|
||||
|
||||
// Shift creator orderIndexes down, going to length+1 so we clear the last one
|
||||
for (var i=orderIndex, max=this._creators.length+1; i<max; i++) {
|
||||
var next = this._creators[i+1] ? this._creators[i+1] : false;
|
||||
|
@ -928,6 +933,7 @@ Zotero.Item.prototype.removeCreator = function(orderIndex) {
|
|||
}
|
||||
this._changedCreators[i] = true;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -2982,6 +2988,10 @@ Zotero.Item.prototype.removeTag = function(tagID) {
|
|||
|
||||
tag.removeItem(this.id);
|
||||
tag.save();
|
||||
|
||||
if (!tag.countLinkedItems()) {
|
||||
Zotero.Prefs.set('purge.tags', true);
|
||||
}
|
||||
}
|
||||
|
||||
Zotero.Item.prototype.removeAllTags = function() {
|
||||
|
|
|
@ -177,6 +177,11 @@ Zotero.Tag.prototype.getLinkedItems = function (asIDs) {
|
|||
}
|
||||
|
||||
|
||||
Zotero.Tag.prototype.countLinkedItems = function () {
|
||||
return this.getLinkedItems().length;
|
||||
}
|
||||
|
||||
|
||||
Zotero.Tag.prototype.addItem = function (itemID) {
|
||||
var current = this.getLinkedItems(true);
|
||||
if (current && current.indexOf(itemID) != -1) {
|
||||
|
@ -536,7 +541,6 @@ Zotero.Tag.prototype.erase = function () {
|
|||
Zotero.DB.commitTransaction();
|
||||
|
||||
Zotero.Prefs.set('purge.tags', true);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -389,6 +389,9 @@ Zotero.Sync.Runner = new function () {
|
|||
throw ("Sync already running in Zotero.Sync.Runner.sync()");
|
||||
}
|
||||
|
||||
// Purge deleted objects so they don't cause sync errors (e.g., long tags)
|
||||
Zotero.purgeDataObjects(true);
|
||||
|
||||
_background = !!background;
|
||||
|
||||
_queue = [
|
||||
|
|
|
@ -974,14 +974,13 @@ var Zotero = new function(){
|
|||
/*
|
||||
* Clear entries that no longer exist from various tables
|
||||
*/
|
||||
this.purgeDataObjects = function () {
|
||||
this.purgeDataObjects = function (skipStoragePurge) {
|
||||
Zotero.Creators.purge();
|
||||
Zotero.Tags.purge();
|
||||
Zotero.Fulltext.purgeUnusedWords();
|
||||
Zotero.Items.purge();
|
||||
|
||||
var ZU = new Zotero.Utilities;
|
||||
if (Zotero.Sync.Storage.active && ZU.probability(10)) {
|
||||
if (!skipStoragePurge && Zotero.Sync.Storage.active && Zotero.Utilities.prototype.probability(10)) {
|
||||
Zotero.Sync.Storage.purgeDeletedStorageFiles();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user