[Pkg-mozext-commits] [itsalltext] 03/09: Really recover last used file when more than one previous file exist
David Prévot
taffit at moszumanska.debian.org
Fri Oct 30 20:34:13 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 4ee65d54a7da5b97687a3cff3346990d229797b4
Author: Xabier Oneca <xoneca at gmail.com>
Date: Thu Feb 26 17:19:53 2015 +0100
Really recover last used file when more than one previous file exist
In `initFromExistingFile()`, the first file with the same base is picked and its extension used. With this patch the **really** last modified file is picked. All other versions are removed, like before.
---
src/chrome/content/cacheobj.js | 18 ++++++++++++------
1 file changed, 12 insertions(+), 6 deletions(-)
diff --git a/src/chrome/content/cacheobj.js b/src/chrome/content/cacheobj.js
index 6829fb5..404a158 100644
--- a/src/chrome/content/cacheobj.js
+++ b/src/chrome/content/cacheobj.js
@@ -273,6 +273,8 @@ CacheObj.prototype.initFromExistingFile = function () {
fobj = itsalltext.factoryFile(itsalltext.getWorkingDir()),
entries,
ext = null,
+ last_mtime = 0,
+ prev_found = null,
tmpfiles = /(\.bak|.tmp|~)$/,
entry;
if (fobj.exists() && fobj.isDirectory()) {
@@ -282,15 +284,19 @@ CacheObj.prototype.initFromExistingFile = function () {
entry.QueryInterface(Components.interfaces.nsIFile);
if (entry.leafName.indexOf(base) === 0) {
// startswith
- if (ext === null && !entry.leafName.match(tmpfiles)) {
+ if (entry.lastModifiedTime > last_mtime && !entry.leafName.match(tmpfiles)) {
+ if (prev_found !== null) {
+ try {
+ prev_found.remove(false);
+ } catch (e) {
+ //disabled-debug -- itsalltext.debug('unable to remove', entry, 'because:', e);
+ }
+ }
ext = entry.leafName.slice(base.length);
+ last_mtime = entry.lastModifiedTime;
+ prev_found = entry;
continue;
}
- try {
- entry.remove(false);
- } catch (e) {
- //disabled-debug -- itsalltext.debug('unable to remove', entry, 'because:', 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