commit fd2ba1d5b7316f00a45d22bb4bbe3bf8f763392e
parent a62161dfc15cc065fada50cd1d777d8056053892
Author: Dan Stillman <dstillman@zotero.org>
Date: Wed, 12 Jul 2017 02:58:25 -0400
Fix file sync error on Windows from attachment paths with invalid characters
We filter these now, but upgraded databases with bad paths could still
exist and cause errors.
Diffstat:
1 file changed, 18 insertions(+), 10 deletions(-)
diff --git a/chrome/content/zotero/xpcom/storage/storageLocal.js b/chrome/content/zotero/xpcom/storage/storageLocal.js
@@ -380,28 +380,36 @@ Zotero.Sync.Storage.Local = {
catch (e) {
if (e instanceof OS.File.Error) {
let missing = e.becauseNoSuchFile
- // This can happen if a path is too long on Windows,
- // e.g. a file is being accessed on a VM through a share
- // (and probably in other cases).
- || (e.winLastError && e.winLastError == 3)
- // Handle long filenames on OS X/Linux
- || (e.unixErrno && e.unixErrno == 63);
+ // ERROR_PATH_NOT_FOUND: This can happen if a path is too long on Windows, e.g. a
+ // file is being accessed on a VM through a share (and probably in other cases)
+ || e.winLastError == 3
+ // ERROR_INVALID_NAME: This can happen if there's a colon in the name from before
+ // we were filtering
+ || e.winLastError == 123
+ // ERROR_BAD_PATHNAME
+ || e.winLastError == 161;
if (!missing) {
Components.classes["@mozilla.org/net/osfileconstantsservice;1"]
.getService(Components.interfaces.nsIOSFileConstantsService)
.init();
- missing = (e.unixErrno !== undefined && e.unixErrno == OS.Constants.libc.ENOTDIR)
- || (e.winLastError !== undefined && e.winLastError == OS.Constants.libc.ENOTDIR);
+ missing = e.unixErrno == OS.Constants.libc.ENOTDIR
+ // Handle long filenames on OS X/Linux
+ || e.unixErrno == OS.Constants.libc.ENAMETOOLONG;
}
if (missing) {
+ if (!e.becauseNoSuchFile) {
+ Zotero.debug(e, 1);
+ }
Zotero.debug("Marking attachment " + lk + " as missing");
return this.SYNC_STATE_TO_DOWNLOAD;
}
if (e.becauseClosed) {
Zotero.debug("File was closed", 2);
}
- Zotero.debug(e);
- throw new Error(`Error for operation '${e.operation}' for ${path}`);
+ Zotero.debug(e, 1);
+ Zotero.debug(e.unixErrno, 1);
+ Zotero.debug(e.winLastError, 1);
+ throw new Error(`Error for operation '${e.operation}' for ${path}: ${e}`);
}
throw e;
}