[Pkg-mozext-commits] [itsalltext] 410/459: Fixed problems with changing the working dir
David Prévot
taffit at moszumanska.debian.org
Tue Feb 24 23:26:43 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 c29cd682a54ffc8a2293c707a95ae7c6d1346716
Author: Christian Höltje <docwhat at gerf.org>
Date: Mon May 13 22:28:36 2013 -0400
Fixed problems with changing the working dir
It wasn't being created if it didn't exist already.
---
src/chrome/content/cacheobj.js | 31 ++++++++++++++------------
src/chrome/content/itsalltext.js | 48 ++++++++++++++++++++++------------------
src/chrome/content/monitor.js | 2 +-
3 files changed, 45 insertions(+), 36 deletions(-)
diff --git a/src/chrome/content/cacheobj.js b/src/chrome/content/cacheobj.js
index e425981..1bbbc6f 100644
--- a/src/chrome/content/cacheobj.js
+++ b/src/chrome/content/cacheobj.js
@@ -228,23 +228,26 @@ CacheObj.prototype.getFile = function () {
CacheObj.prototype.initFromExistingFile = function () {
var base = this.base_filename,
fobj = itsalltext.factoryFile(itsalltext.getWorkingDir()),
- entries = fobj.directoryEntries,
+ entries,
ext = null,
tmpfiles = /(\.bak|.tmp|~)$/,
entry;
- while (entries.hasMoreElements()) {
- entry = entries.getNext();
- entry.QueryInterface(Components.interfaces.nsIFile);
- if (entry.leafName.indexOf(base) === 0) {
- // startswith
- if (ext === null && !entry.leafName.match(tmpfiles)) {
- ext = entry.leafName.slice(base.length);
- continue;
- }
- try {
- entry.remove(false);
- } catch (e) {
- //disabled-debug -- itsalltext.debug('unable to remove', entry, 'because:', e);
+ if (fobj.exists() && fobj.isDirectory()) {
+ entries = fobj.directoryEntries;
+ while (entries.hasMoreElements()) {
+ entry = entries.getNext();
+ entry.QueryInterface(Components.interfaces.nsIFile);
+ if (entry.leafName.indexOf(base) === 0) {
+ // startswith
+ if (ext === null && !entry.leafName.match(tmpfiles)) {
+ ext = entry.leafName.slice(base.length);
+ continue;
+ }
+ try {
+ entry.remove(false);
+ } catch (e) {
+ //disabled-debug -- itsalltext.debug('unable to remove', entry, 'because:', e);
+ }
}
}
}
diff --git a/src/chrome/content/itsalltext.js b/src/chrome/content/itsalltext.js
index 829256e..1d750a3 100644
--- a/src/chrome/content/itsalltext.js
+++ b/src/chrome/content/itsalltext.js
@@ -59,13 +59,6 @@ var ItsAllText = function () {
getService(Components.interfaces.nsIProperties).
get("ProfD", Components.interfaces.nsIFile);
fobj.append(that.MYSTRING);
- if (!fobj.exists()) {
- fobj.create(Components.interfaces.nsIFile.DIRECTORY_TYPE,
- parseInt('0700', 8));
- }
- if (!fobj.isDirectory()) {
- that.error(that.localeFormat('problem_making_directory', [fobj.path]));
- }
return fobj.path;
};
@@ -263,15 +256,26 @@ var ItsAllText = function () {
*/
that.getWorkingDir = function () {
var workingdir = that.preferences.workingdir,
- default_workingdir;
+ default_workingdir,
+ fobj;
if (!workingdir) {
default_workingdir = that.getDefaultWorkingDir();
that.preferences.private_set('workingdir', default_workingdir);
- return default_workingdir;
- } else {
- return workingdir;
+ workingdir = default_workingdir;
+ }
+
+ // Verify the directory exists.
+ fobj = that.factoryFile(workingdir);
+ if (!fobj.exists()) {
+ fobj.create(Components.interfaces.nsIFile.DIRECTORY_TYPE,
+ parseInt('0700', 8));
}
+ if (!fobj.isDirectory()) {
+ that.error(that.localeFormat('problem_making_directory', [workingdir]));
+ }
+
+ return workingdir;
};
/**
@@ -901,16 +905,18 @@ ItsAllText.prototype.cleanWorkingDir = function (force) {
var last_week, fobj, entries, entry;
last_week = Date.now() - (1000 * 60 * 60 * 24 * 7);
fobj = this.factoryFile(this.getWorkingDir());
- entries = fobj.directoryEntries;
-
- while (entries.hasMoreElements()) {
- entry = entries.getNext();
- entry.QueryInterface(Components.interfaces.nsIFile);
- if (force || !entry.exists() || entry.lastModifiedTime < last_week) {
- try {
- entry.remove(false);
- } catch (e) {
- this.log('unable to remove', entry, 'because:', e);
+ if (fobj.exists() && fobj.isDirectory()) {
+ entries = fobj.directoryEntries;
+
+ while (entries.hasMoreElements()) {
+ entry = entries.getNext();
+ entry.QueryInterface(Components.interfaces.nsIFile);
+ if (force || !entry.exists() || entry.lastModifiedTime < last_week) {
+ try {
+ entry.remove(false);
+ } catch (e) {
+ this.log('unable to remove', entry, 'because:', e);
+ }
}
}
}
diff --git a/src/chrome/content/monitor.js b/src/chrome/content/monitor.js
index 8cd97cc..5332250 100644
--- a/src/chrome/content/monitor.js
+++ b/src/chrome/content/monitor.js
@@ -33,7 +33,7 @@ function Monitor() {
}
Monitor.prototype.hitched_destroy = function () {
- delete itsalltext;
+ delete this.itsalltext;
};
Monitor.prototype.hitched_restart = function () {
--
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