diff options
author | zyp <zyp@localhost> | 2006-11-20 15:19:42 +0100 |
---|---|---|
committer | zyp <zyp@localhost> | 2006-11-20 15:19:42 +0100 |
commit | 99cb5530ce1b0fdffd6a1a3919cb12fd38522b34 (patch) | |
tree | 8268ba7e6caf5237f9addae2cffc266589e4d062 | |
parent | f02cce5aa1359bba2a717d26d699a58220221c16 (diff) |
[project @ zyp-20061120141942-788dd99f008634af]
[project @ 67]
Fixed bug if missing xattr.
-rw-r--r-- | anidb.py | 2 | ||||
-rw-r--r-- | pyanidb/hash.py | 6 |
2 files changed, 6 insertions, 2 deletions
@@ -90,7 +90,7 @@ for name in args: for root, subdirs, subfiles in os.walk(name): subdirs.sort() subfiles.sort() - files += [os.path.join(root, file) for file in subfiles if sum([file.endswith('.' + suffix) for suffix in options.suffix])] + files += [os.path.join(root, file) for file in subfiles if True in [file.endswith('.' + suffix) for suffix in options.suffix]] if not files: print blue('Nothing to do.') diff --git a/pyanidb/hash.py b/pyanidb/hash.py index a748f9e..4aab45f 100644 --- a/pyanidb/hash.py +++ b/pyanidb/hash.py @@ -12,7 +12,7 @@ class File: self.cached = False if cache: self.read_cache() - if sum([not hasattr(self, a) for a in algorithms]): + if False in [hasattr(self, a) for a in algorithms]: self.cached = False h = multihash.hash_file(name, algorithms) for a in algorithms: @@ -20,6 +20,8 @@ class File: self.write_cache() def read_cache(self): + if not xattr: + return cache = dict([(n[13:], xattr.getxattr(self.name, n)) for n in xattr.listxattr(self.name) if n.startswith('user.pyanidb.')]) if 'mtime' not in cache or str(int(self.mtime)) != cache.pop('mtime'): return @@ -28,6 +30,8 @@ class File: self.cached = True def write_cache(self): + if not xattr: + return try: self.clear_cache() xattr.setxattr(self.name, 'user.pyanidb.mtime', str(int(self.mtime))) |