[Pkg-mozext-commits] [itsalltext] 166/459: Changed the monitoring pattern to better match what Giuseppe mentioned in my blog. It looks for existing files and watches them, if they exist.

David Prévot taffit at moszumanska.debian.org
Tue Feb 24 23:26:18 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 7d8c8393a603996e31b12397962df37c84dbfd96
Author: Christian Höltje <docwhat at gerf.org>
Date:   Sat Mar 17 22:17:16 2007 -0400

    Changed the monitoring pattern to better match what Giuseppe mentioned in my blog.  It looks for existing files and watches them, if they exist.
---
 chrome/content/cacheobj.js | 33 +++++++++++++++++++++++++++++++++
 1 file changed, 33 insertions(+)

diff --git a/chrome/content/cacheobj.js b/chrome/content/cacheobj.js
index 2e28f0a..0df322d 100644
--- a/chrome/content/cacheobj.js
+++ b/chrome/content/cacheobj.js
@@ -62,6 +62,8 @@ function CacheObj(node) {
     }
     that.setExtension(extension);
 
+    that.initFromExistingFile();
+
     /**
      * A callback for when the textarea/textbox or button has 
      * the mouse waved over it.
@@ -108,6 +110,37 @@ CacheObj.prototype.setExtension = function(ext) {
 };
 
 /**
+ * This function looks for an existing file and starts to monitor
+ * if the file exists already.  It also deletes all existing files for
+ * this cache object.
+ */
+CacheObj.prototype.initFromExistingFile = function() {
+    var base = this.base_filename;
+    var fobj = ItsAllText.getEditDir();
+    var entries = fobj.directoryEntries;
+    var ext = null;
+    while (entries.hasMoreElements()) {
+        var entry = entries.getNext();
+        entry.QueryInterface(Components.interfaces.nsIFile);
+        if (entry.leafName.indexOf(base) === 0) {
+            // startswith
+            if (ext === null) {
+                ext = entry.leafName.slice(base.length);
+            }
+            try{
+                entry.remove(false);
+            } catch(e) {
+                that.debug('unable to remove',entry,'because:',e);
+            }
+        }
+    }
+    if (ext !== null) {
+        this.setExtension(ext);
+        this._is_watching = true;
+    }
+}
+
+/**
  * Returns a unique identifier for the node, within the document.
  * @returns {String} the unique identifier.
  */

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