[Pkg-mozext-commits] [itsalltext] 01/09: Windows has very short filename length

David Prévot taffit at moszumanska.debian.org
Sat Feb 28 15:56:26 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 94512e23efc36c48c918e0609df4f75894efc397
Author: Christian Höltje <docwhat at gerf.org>
Date:   Wed Feb 25 21:14:30 2015 -0500

    Windows has very short filename length
    
    Depending on the version, etc. it is 129 characters.  I've set
    the max "base_filename" to 100 characters to be safe.
    
    Fixes #65
---
 src/chrome/content/cacheobj.js | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/src/chrome/content/cacheobj.js b/src/chrome/content/cacheobj.js
index 568f174..62f393d 100644
--- a/src/chrome/content/cacheobj.js
+++ b/src/chrome/content/cacheobj.js
@@ -86,14 +86,15 @@ function CacheObj(node) {
             doc.location.search ? doc.location.search : '?',
             doc.location.pathname,
             that.node_id].join(':')
-    ).slice(0, 10);
+    ).slice(0, 8);
 
     /* Determine the local filename for the document. */
-
+    // Windows has a max filename length of 129 chars.
     starting_urlname = (doc.location.host + doc.location.pathname)
         .replace(/[\/\\]/g, '_')
         .replace(/\.\.+/g, '.')
-        .replace(/[^a-z0-9_.-]+/gi, '');
+        .replace(/[^a-z0-9_.-]+/gi, '')
+        .substring(0, 100);
     //disabled-debug -- itsalltext.debug("starting_urlname:", starting_urlname);
     for (urlname = starting_urlname; ;) {
         that.base_filename = [window.encodeURIComponent(urlname), hash].join('.');
@@ -110,14 +111,19 @@ function CacheObj(node) {
                     continue;
                 }
                 break;
+              case 'NS_ERROR_FILE_NOT_FOUND':
+                break;
               case 'NS_ERROR_FILE_TARGET_DOES_NOT_EXIST':
                 break;
               default:
+                itsalltext.debug("File naming error:", e);
                 throw e;
             }
         }
         break;
     }
+    that.base_filename = [window.encodeURIComponent(urlname), hash].join('.');
+    //disabled-debug -- itsalltext.debug("base_filename", that.base_filename);
 
     /* The current extension.
      * @type String
@@ -245,7 +251,6 @@ CacheObj.prototype.getExtension = function () {
     return this.extension;
 }
 
-
 /**
  * Returns an nsIFile object for the current file.
  * @returns {nsIFile} A file object for the directory.

-- 
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