commit 08d322932d90a96ec0e27268c955fe9f135a68a8
parent 773a93f55d77f4cb91161480b666ca9cfdacba4a
Author: Dan Stillman <dstillman@zotero.org>
Date: Sun, 8 Oct 2017 04:42:42 -0400
Fix sync error from invalid link mode in database
And add cleanup step to DB integrity check
Diffstat:
3 files changed, 10 insertions(+), 1 deletion(-)
diff --git a/chrome/content/zotero/xpcom/attachments.js b/chrome/content/zotero/xpcom/attachments.js
@@ -24,6 +24,7 @@
*/
Zotero.Attachments = new function(){
+ // Keep in sync with Zotero.Schema.integrityCheck()
this.LINK_MODE_IMPORTED_FILE = 0;
this.LINK_MODE_IMPORTED_URL = 1;
this.LINK_MODE_LINKED_FILE = 2;
diff --git a/chrome/content/zotero/xpcom/data/item.js b/chrome/content/zotero/xpcom/data/item.js
@@ -349,7 +349,10 @@ Zotero.Item.prototype._parseRowData = function(row) {
break;
case 'attachmentLinkMode':
- val = val !== null ? parseInt(val) : false;
+ val = val !== null
+ ? parseInt(val)
+ // Shouldn't happen
+ : Zotero.Attachments.LINK_MODE_IMPORTED_URL;
break;
case 'attachmentPath':
diff --git a/chrome/content/zotero/xpcom/schema.js b/chrome/content/zotero/xpcom/schema.js
@@ -1329,6 +1329,11 @@ Zotero.Schema = new function(){
[
"SELECT COUNT(*) > 1 FROM fulltextItems WHERE itemID NOT IN (SELECT itemID FROM items WHERE itemTypeID=14)",
"DELETE FROM fulltextItems WHERE itemID NOT IN (SELECT itemID FROM items WHERE itemTypeID=14)"
+ ],
+ // Invalid link mode -- set to imported url
+ [
+ "SELECT COUNT(*) > 1 FROM itemAttachments WHERE linkMode NOT IN (0,1,2,3)",
+ "UPDATE itemAttachments SET linkMode=1 WHERE linkMode NOT IN (0,1,2,3)"
]
];