From 86dda4e0183f6753c89fea4ba5b61cf694439c19 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Sat, 3 Mar 2012 05:57:16 -0500 Subject: [PATCH] Ignore a file sync error on Windows with long ad junk files For some reason on some Windows (XP, 7) systems a long path close to 255 characters long can pass destFile.create() and fail zipReader.extract(). This seems like a Mozilla bug, but until we find a better fix just ignore the error for the only files where we've seen it, which are advertising script artifacts with very long uninterrupted filenames (which we should skip when saving anyway). Also close zipReader after an extraction error --- chrome/content/zotero/xpcom/storage.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/chrome/content/zotero/xpcom/storage.js b/chrome/content/zotero/xpcom/storage.js index c2cde12672..e3a2bdd43b 100644 --- a/chrome/content/zotero/xpcom/storage.js +++ b/chrome/content/zotero/xpcom/storage.js @@ -1111,6 +1111,7 @@ Zotero.Sync.Storage = new function () { Components.utils.reportError(msg + " in " + funcName); continue; } + try { destFile.create(Components.interfaces.nsIFile.NORMAL_FILE_TYPE, 0644); } @@ -1234,6 +1235,20 @@ Zotero.Sync.Storage = new function () { } catch (e) { Zotero.debug(destFile.path); + + // For advertising junk files, ignore a bug on Windows where + // destFile.create() works but zipReader.extract() doesn't + // when the path length is close to 255. + if (destFile.leafName.match(/[a-zA-Z0-9]{130,}/)) { + var msg = "Ignoring error extracting '" + destFile.path + "'"; + Zotero.debug(msg, 2); + Zotero.debug(e, 2); + Components.utils.reportError(msg + " in " + funcName); + continue; + } + + zipReader.close(); + Zotero.File.checkFileAccessError(e, destFile, 'create'); }