[Pkg-mozext-commits] [itsalltext] 115/459: * added force flag to cleanEditDir() in case I need it. * only monitor files after an edit event.

David Prévot taffit at moszumanska.debian.org
Tue Feb 24 23:26:12 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 e41a9a07a40452e8fa0aa52b9728b50709098ae4
Author: docwhat at gerf.org <docwhat at gerf.org>
Date:   Thu Feb 8 12:11:27 2007 -0500

    * added force flag to cleanEditDir() in case I need it.
    * only monitor files after an edit event.
---
 chrome/content/cacheobj.js   | 20 +++++++++++++++++++-
 chrome/content/itsalltext.js |  9 ++++-----
 2 files changed, 23 insertions(+), 6 deletions(-)

diff --git a/chrome/content/cacheobj.js b/chrome/content/cacheobj.js
index 6e0eb46..0383253 100644
--- a/chrome/content/cacheobj.js
+++ b/chrome/content/cacheobj.js
@@ -18,6 +18,7 @@ function CacheObj(node) {
     that.node = node;
     that.button = null;
     that.initial_color = 'transparent';
+    that._is_watching = false;
      
     that.node_id = that.getNodeIdentifier(node);
     var doc = node.ownerDocument;
@@ -200,6 +201,7 @@ CacheObj.prototype.edit = function(extension, retried) {
         var args = [filename];
         var result = {};
         process.run(false, args, args.length, result);
+        this._is_watching = true;
     } catch(e) {
         window.openDialog('chrome://itsalltext/chrome/preferences.xul',
                           "Preferences", 
@@ -212,6 +214,21 @@ CacheObj.prototype.edit = function(extension, retried) {
 };
 
 /**
+ * Delete the file from disk.
+ */
+CacheObj.prototype.delete = function() {
+    if(this.file.exists()) {
+        try {
+            this.file.remove();
+        } catch(e) {
+            that.debug('delete(',this.file.path,'): ',e);
+            return false;
+        }
+    }
+    return true;
+};
+
+/**
  * Read the file from disk.
  */
 CacheObj.prototype.read = function() {
@@ -254,7 +271,8 @@ CacheObj.prototype.read = function() {
  */
  CacheObj.prototype.hasChanged = function() {
      /* Check exists.  Check ts and size. */
-     if(!this.file.exists() ||
+     if(!this._is_watching ||
+        !this.file.exists() ||
         !this.file.isReadable() ||
         (this.file.lastModifiedTime == this.timestamp && 
          this.file.fileSize         == this.size)) {
diff --git a/chrome/content/itsalltext.js b/chrome/content/itsalltext.js
index b696f01..ebf7745 100644
--- a/chrome/content/itsalltext.js
+++ b/chrome/content/itsalltext.js
@@ -111,18 +111,17 @@ var ItsAllText = function() {
     };
 
     /**
-     * Cleans out the edit directory, deleting all files.
+     * Cleans out the edit directory, deleting all old files.
      */
-    that.cleanEditDir = function() {
+    that.cleanEditDir = function(force) {
+        force = (force && typeof(force) != 'undefined');
         var last_week = Date.now() - (1000*60*60*24*7);
         var fobj = that.getEditDir();
-        //return dir.directoryEntries;
-        // file is the given directory (nsIFile)
         var entries = fobj.directoryEntries;
         while (entries.hasMoreElements()) {
             var entry = entries.getNext();
             entry.QueryInterface(Components.interfaces.nsIFile);
-            if(entry.lastModifiedTime < last_week) {
+            if(force || entry.lastModifiedTime < last_week) {
                 try{
                     entry.remove(false);
                 } catch(e) {

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