From 7eeb666894ebedcdda816a9bba79767072611ffc Mon Sep 17 00:00:00 2001 From: Abe Jellinek Date: Wed, 30 Apr 2025 01:06:40 -0400 Subject: [PATCH] Skip invalid relative path when changing LABD (#5239) --- .../preferences/preferences_advanced.js | 49 +++++++------------ test/tests/preferences_advancedTest.js | 24 +++++++++ 2 files changed, 43 insertions(+), 30 deletions(-) diff --git a/chrome/content/zotero/preferences/preferences_advanced.js b/chrome/content/zotero/preferences/preferences_advanced.js index 0eab089f58..3531df6e28 100644 --- a/chrome/content/zotero/preferences/preferences_advanced.js +++ b/chrome/content/zotero/preferences/preferences_advanced.js @@ -593,7 +593,7 @@ Zotero_Preferences.Attachment_Base_Directory = { }, - changePath: Zotero.Promise.coroutine(function* (basePath) { + changePath: async function (basePath) { Zotero.debug(`New base directory is ${basePath}`); if (Zotero.File.directoryContains(Zotero.DataDirectory.dir, basePath)) { @@ -605,38 +605,37 @@ Zotero_Preferences.Attachment_Base_Directory = { ); } - // Find all current attachments with relative attachment paths - var sql = "SELECT itemID FROM itemAttachments WHERE linkMode=? AND path LIKE ?"; - var params = [ - Zotero.Attachments.LINK_MODE_LINKED_FILE, - Zotero.Attachments.BASE_PATH_PLACEHOLDER + "%" - ]; - var oldRelativeAttachmentIDs = yield Zotero.DB.columnQueryAsync(sql, params); - - //Find all attachments on the new base path + // Find all attachments on the new base path var sql = "SELECT itemID FROM itemAttachments WHERE linkMode=?"; var params = [Zotero.Attachments.LINK_MODE_LINKED_FILE]; - var allAttachments = yield Zotero.DB.columnQueryAsync(sql, params); + var allAttachments = await Zotero.DB.columnQueryAsync(sql, params); var newAttachmentPaths = {}; var numNewAttachments = 0; var numOldAttachments = 0; - for (let i=0; i