From 731af5414aef8db0c28e2dcdd9ba45526d07e96b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20Borgstr=C3=B6m?= Date: Tue, 4 Jan 2011 23:16:55 +0100 Subject: [PATCH] Fix store and cache dir auto ignore --- darc/archiver.py | 14 ++++++++------ darc/cache.py | 2 ++ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/darc/archiver.py b/darc/archiver.py index 01ce99987..7a8ce8250 100644 --- a/darc/archiver.py +++ b/darc/archiver.py @@ -60,25 +60,25 @@ class Archiver(object): archive = Archive(store, keychain) cache = Cache(store, keychain) # Add darc cache dir to inode_skip list - skip_inodes = [] + skip_inodes = set() try: st = os.stat(Cache.cache_dir_path()) - skip_inodes.append((st.st_ino, st.st_dev)) + skip_inodes.add((st.st_ino, st.st_dev)) except IOError: pass # Add local store dir to inode_skip list if not args.archive.host: try: st = os.stat(args.archive.path) - skip_inodes.append((st.st_ino, st.st_dev)) + skip_inodes.add((st.st_ino, st.st_dev)) except IOError: pass for path in args.paths: - self._process(archive, cache, args.patterns, unicode(path)) + self._process(archive, cache, args.patterns, skip_inodes, unicode(path)) archive.save(args.archive.archive, cache) return self.exit_code - def _process(self, archive, cache, patterns, path): + def _process(self, archive, cache, patterns, skip_inodes, path): if exclude_path(path, patterns): return try: @@ -86,6 +86,8 @@ class Archiver(object): except OSError, e: self.print_error('%s: %s', path, e) return + if (st.st_ino, st.st_dev) in skip_inodes: + return self.print_verbose(path) if stat.S_ISDIR(st.st_mode): archive.process_dir(path, st) @@ -95,7 +97,7 @@ class Archiver(object): self.print_error('%s: %s', path, e) else: for filename in entries: - self._process(archive, cache, patterns, + self._process(archive, cache, patterns, skip_inodes, os.path.join(path, filename)) elif stat.S_ISLNK(st.st_mode): archive.process_symlink(path, st) diff --git a/darc/cache.py b/darc/cache.py index 3ffcf4afe..9f1559d79 100644 --- a/darc/cache.py +++ b/darc/cache.py @@ -85,6 +85,8 @@ class Cache(object): def commit(self): """Commit transaction """ + if not self.txn_active: + return with open(os.path.join(self.path, 'files'), 'wb') as fd: for item in self.files.iteritems(): msgpack.pack(item, fd)