commit d4287e4459012a9b9e20f72596a26e3cbc8038be
parent c2db7b53b19fbc2bdaa8a09f2d75b62ac6ee4b9d
Author: Dan Stillman <dstillman@zotero.org>
Date: Tue, 2 Aug 2011 22:41:09 +0000
Skip and log too-long filenames on Linux (since they're most likely gibberish advertising files anyway)
Diffstat:
1 file changed, 36 insertions(+), 11 deletions(-)
diff --git a/chrome/content/zotero/xpcom/storage.js b/chrome/content/zotero/xpcom/storage.js
@@ -915,12 +915,15 @@ Zotero.Sync.Storage = new function () {
else if (e.name == "NS_ERROR_FAILURE" && destFile.leafName.length >= 244) {
nameLength = true;
}
- // ecrypt (on Ubuntu, at least) can result in a lower limit —
- // not much we can do about this, but throw a specific error
+ // Filesystem encryption (or, more specifically, filename encryption)
+ // can result in a lower limit -- not much we can do about this,
+ // but log a warning and skip the file
else if (e.name == "NS_ERROR_FAILURE" && Zotero.isLinux && destFile.leafName.length > 130) {
- var e = "Error creating file '" + destFile.leafName + "'\n\n"
- + "Check whether you are using a filesystem encryption such as eCryptfs "
- + "that results in a filename length limit below 255 bytes.";
+ Zotero.debug(e);
+ var msg = "Error creating file '" + destFile.leafName + "'\n\n"
+ + "See http://www.zotero.org/support/kb/encrypted_filenames for more information.";
+ Components.utils.reportError(msg);
+ return;
}
if (windowsLength || nameLength) {
@@ -1113,13 +1116,16 @@ Zotero.Sync.Storage = new function () {
else if (e.name == "NS_ERROR_FAILURE" && destFile.leafName.length >= 244) {
nameLength = true;
}
- // ecrypt (on Ubuntu, at least) can result in a lower limit --
- // not much we can do about this, but log a warning
+ // Filesystem encryption (or, more specifically, filename encryption)
+ // can result in a lower limit -- not much we can do about this,
+ // but log a warning and skip the file
else if (e.name == "NS_ERROR_FAILURE" && Zotero.isLinux && destFile.leafName.length > 130) {
- var msg = "Error creating file '" + destFile.leafName + "' "
- + "(Are you using filesystem encryption such as ecrypt "
- + "that results in a filename length limit below 255 bytes?)";
+ Zotero.debug(e);
+ // TODO: localize
+ var msg = "Error creating file '" + destFile.leafName + "'. "
+ + "See http://www.zotero.org/support/kb/encrypted_filenames for more information.";
Components.utils.reportError(msg);
+ continue;
}
if (windowsLength || nameLength) {
@@ -1168,7 +1174,26 @@ Zotero.Sync.Storage = new function () {
Zotero.debug(msg, 2);
Components.utils.reportError(msg);
- destFile.create(Components.interfaces.nsIFile.NORMAL_FILE_TYPE, 0644);
+ try {
+ destFile.create(Components.interfaces.nsIFile.NORMAL_FILE_TYPE, 0644);
+ }
+ catch (e) {
+ // See above
+ if (e.name == "NS_ERROR_FAILURE" && Zotero.isLinux && destFile.leafName.length > 130) {
+ Zotero.debug(e);
+ // TODO: localize
+ var msg = "Error creating file '" + destFile.leafName + "'. "
+ + "See http://www.zotero.org/support/kb/encrypted_filenames for more information.";
+ Components.utils.reportError(msg);
+ continue;
+ }
+
+ zipReader.close();
+
+ Components.utils.reportError(e);
+ var msg = Zotero.getString('sync.storage.error.fileNotCreated', parentDir.leafName + '/' + fileName);
+ throw(msg);
+ }
if (primaryFile) {
renamed = true;