commit 4af73f4a5261282f492b3a4f9b4f14567ee55107
parent 8bdac7015be46ae834565949738b76ca01340740
Author: Dan Stillman <dstillman@zotero.org>
Date: Thu, 8 Aug 2013 13:41:34 -0400
Fix file sync error in Fx23+ for empty attachment paths
And fix reporting of non-OS.File file sync errors
Diffstat:
1 file changed, 14 insertions(+), 7 deletions(-)
diff --git a/chrome/content/zotero/xpcom/storage.js b/chrome/content/zotero/xpcom/storage.js
@@ -938,7 +938,7 @@ Zotero.Sync.Storage = new function () {
Components.utils.import("resource://gre/modules/osfile.jsm")
let checkItems = function () {
- if (!items.length) return;
+ if (!items.length) return Q();
//Zotero.debug("Memory usage: " + memmgr.resident);
@@ -948,6 +948,11 @@ Zotero.Sync.Storage = new function () {
//Zotero.debug("Checking attachment file for item " + lk);
let nsIFile = item.getFile(row, true);
+ if (!nsIFile) {
+ Zotero.debug("Marking pathless attachment " + lk + " as in-sync");
+ updatedStates[item.id] = Zotero.Sync.Storage.SYNC_STATE_IN_SYNC;
+ return checkItems();
+ }
let file = null;
return Q(OS.File.open(nsIFile.path))
.then(function (promisedFile) {
@@ -1023,7 +1028,7 @@ Zotero.Sync.Storage = new function () {
.then(function (fileHash) {
if (row.hash && row.hash == fileHash) {
Zotero.debug("Mod time didn't match (" + fmtime + "!=" + mtime + ") "
- + "but hash did for " + file.leafName + " for item " + lk
+ + "but hash did for " + nsIFile.leafName + " for item " + lk
+ " -- updating file mod time");
try {
nsIFile.lastModifiedTime = row.mtime;
@@ -1054,14 +1059,16 @@ Zotero.Sync.Storage = new function () {
return;
}
- if (e instanceof OS.File.Error && e.becauseClosed) {
- Zotero.debug("File was closed", 2);
- }
- else {
+ if (e instanceof OS.File.Error) {
+ if (e.becauseClosed) {
+ Zotero.debug("File was closed", 2);
+ }
Zotero.debug(e);
Zotero.debug(e.toString());
+ throw new Error("Error " + e.operation + " " + nsIFile.path);
}
- throw new Error("Error " + e.operation + " " + nsIFile.path);
+
+ throw e;
})
.then(function () {
return checkItems();