From f3810befdef76418d1199b4d2d0b17ebb59a737e Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Fri, 4 Sep 2026 11:20:06 -0400 Subject: [PATCH] Show file access error for NS_ERROR_FILE_FS_CORRUPTED Windows returns this for ERROR_FILE_CORRUPT/ERROR_DISK_CORRUPT. It's not in xpc.msg, so the exception has an empty name and isn't in Components.results, and it was falling through to the generic file sync error instead of the file access error with the path. Show a message about the reported corruption in place of the usual permissions advice. https://forums.zotero.org/discussion/133592/ --- chrome/content/zotero/xpcom/file.js | 17 ++++++++++++++--- chrome/locale/en-US/zotero/zotero.ftl | 2 ++ 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/chrome/content/zotero/xpcom/file.js b/chrome/content/zotero/xpcom/file.js index d39176129d..b9e20f0df2 100644 --- a/chrome/content/zotero/xpcom/file.js +++ b/chrome/content/zotero/xpcom/file.js @@ -1727,16 +1727,27 @@ Zotero.File = new function () { if (e.name == 'NS_ERROR_FILE_ACCESS_DENIED' || e.name == 'NS_ERROR_FILE_IS_LOCKED' // These show up on some Windows systems || e.name == 'NS_ERROR_FAILURE' || e.name == 'NS_ERROR_FILE_NOT_FOUND' + // NS_ERROR_FILE_FS_CORRUPTED (Windows ERROR_FILE_CORRUPT/ERROR_DISK_CORRUPT), which + // isn't in Components.results or exposed as an exception name + || e.result == 0x80520016 // OS.File.Error || e.becauseAccessDenied || e.becauseNoSuchFile // IOUtils || e.name == 'NotAllowedError' || e.name == 'ReadOnlyError' || e.name == 'NotFoundError') { - let checkFileWindows = Zotero.getString('file.accessError.message.windows'); - let checkFileOther = Zotero.getString('file.accessError.message.other'); + let checkFile; + if (e.result == 0x80520016) { + checkFile = Zotero.ftl.formatValueSync('file-access-error-fs-corrupted'); + } + else if (Zotero.isWin) { + checkFile = Zotero.getString('file.accessError.message.windows'); + } + else { + checkFile = Zotero.getString('file.accessError.message.other'); + } let msg = str + "\n\n" - + (Zotero.isWin ? checkFileWindows : checkFileOther) + + checkFile + "\n\n" + Zotero.getString('file.accessError.restart'); diff --git a/chrome/locale/en-US/zotero/zotero.ftl b/chrome/locale/en-US/zotero/zotero.ftl index 169d32c0dc..7eabafada6 100644 --- a/chrome/locale/en-US/zotero/zotero.ftl +++ b/chrome/locale/en-US/zotero/zotero.ftl @@ -362,6 +362,8 @@ item-button-view-online = file-renaming-file-renamed-to = File renamed to { $filename } +file-access-error-fs-corrupted = { -os-name } reported that the file or disk is corrupted. Run a disk check on the drive containing the file. + itembox-button-options = .tooltiptext = Open context menu itembox-button-merge =