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.
This commit is contained in:
parent
a62161dfc1
commit
fd2ba1d5b7
|
@ -380,28 +380,36 @@ Zotero.Sync.Storage.Local = {
|
||||||
catch (e) {
|
catch (e) {
|
||||||
if (e instanceof OS.File.Error) {
|
if (e instanceof OS.File.Error) {
|
||||||
let missing = e.becauseNoSuchFile
|
let missing = e.becauseNoSuchFile
|
||||||
// This can happen if a path is too long on Windows,
|
// ERROR_PATH_NOT_FOUND: This can happen if a path is too long on Windows, e.g. a
|
||||||
// e.g. a file is being accessed on a VM through a share
|
// file is being accessed on a VM through a share (and probably in other cases)
|
||||||
// (and probably in other cases).
|
|| e.winLastError == 3
|
||||||
|| (e.winLastError && e.winLastError == 3)
|
// ERROR_INVALID_NAME: This can happen if there's a colon in the name from before
|
||||||
// Handle long filenames on OS X/Linux
|
// we were filtering
|
||||||
|| (e.unixErrno && e.unixErrno == 63);
|
|| e.winLastError == 123
|
||||||
|
// ERROR_BAD_PATHNAME
|
||||||
|
|| e.winLastError == 161;
|
||||||
if (!missing) {
|
if (!missing) {
|
||||||
Components.classes["@mozilla.org/net/osfileconstantsservice;1"]
|
Components.classes["@mozilla.org/net/osfileconstantsservice;1"]
|
||||||
.getService(Components.interfaces.nsIOSFileConstantsService)
|
.getService(Components.interfaces.nsIOSFileConstantsService)
|
||||||
.init();
|
.init();
|
||||||
missing = (e.unixErrno !== undefined && e.unixErrno == OS.Constants.libc.ENOTDIR)
|
missing = e.unixErrno == OS.Constants.libc.ENOTDIR
|
||||||
|| (e.winLastError !== undefined && e.winLastError == OS.Constants.libc.ENOTDIR);
|
// Handle long filenames on OS X/Linux
|
||||||
|
|| e.unixErrno == OS.Constants.libc.ENAMETOOLONG;
|
||||||
}
|
}
|
||||||
if (missing) {
|
if (missing) {
|
||||||
|
if (!e.becauseNoSuchFile) {
|
||||||
|
Zotero.debug(e, 1);
|
||||||
|
}
|
||||||
Zotero.debug("Marking attachment " + lk + " as missing");
|
Zotero.debug("Marking attachment " + lk + " as missing");
|
||||||
return this.SYNC_STATE_TO_DOWNLOAD;
|
return this.SYNC_STATE_TO_DOWNLOAD;
|
||||||
}
|
}
|
||||||
if (e.becauseClosed) {
|
if (e.becauseClosed) {
|
||||||
Zotero.debug("File was closed", 2);
|
Zotero.debug("File was closed", 2);
|
||||||
}
|
}
|
||||||
Zotero.debug(e);
|
Zotero.debug(e, 1);
|
||||||
throw new Error(`Error for operation '${e.operation}' for ${path}`);
|
Zotero.debug(e.unixErrno, 1);
|
||||||
|
Zotero.debug(e.winLastError, 1);
|
||||||
|
throw new Error(`Error for operation '${e.operation}' for ${path}: ${e}`);
|
||||||
}
|
}
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user