[Pkg-mozext-commits] [itsalltext] 445/459: Handle NS_ERROR_FILE_NAME_TOO_LONG and try with a shorter file name.
David Prévot
taffit at moszumanska.debian.org
Tue Feb 24 23:26:47 UTC 2015
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch master
in repository itsalltext.
commit 5d452094ca30e7db4f57668fdfe752a580d5b040
Author: Akinori MUSHA <knu at idaemons.org>
Date: Fri Dec 19 22:35:45 2014 +0900
Handle NS_ERROR_FILE_NAME_TOO_LONG and try with a shorter file name.
---
src/chrome/content/cacheobj.js | 29 +++++++++++++++++++++++++----
1 file changed, 25 insertions(+), 4 deletions(-)
diff --git a/src/chrome/content/cacheobj.js b/src/chrome/content/cacheobj.js
index 7d8c1be..127ee1a 100644
--- a/src/chrome/content/cacheobj.js
+++ b/src/chrome/content/cacheobj.js
@@ -27,7 +27,7 @@ function CacheObj(node) {
var that = this,
hitch_re = /^hitched_/,
doc = node.ownerDocument,
- basename,
+ urlname,
hash,
method,
extension;
@@ -85,9 +85,30 @@ function CacheObj(node) {
doc.location.search ? doc.location.search : '?',
doc.location.pathname,
that.node_id].join(':')
- );
- basename = window.encodeURIComponent(doc.location.host + doc.location.pathname);
- that.base_filename = [basename, hash.slice(0, 10)].join('.');
+ ).slice(0, 10);
+
+ /* Determine the local filename for the document. */
+ for (urlname = doc.location.host + doc.location.pathname; ;) {
+ that.base_filename = [window.encodeURIComponent(urlname), hash].join('.');
+ try {
+ // Hope isWritable() would work here, but it throws
+ // NS_ERROR_FILE_TARGET_DOES_NOT_EXIST if the file is
+ // nonexistent.
+ this.getFile().isFile();
+ } catch (e) {
+ switch (e.name) {
+ case 'NS_ERROR_FILE_NAME_TOO_LONG':
+ if (urlname.length > 0) {
+ urlname = urlname.slice(0, -1);
+ continue;
+ }
+ break;
+ }
+ throw e;
+ }
+ break;
+ }
+
/* The current extension.
* @type String
*/
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mozext/itsalltext.git
More information about the Pkg-mozext-commits
mailing list