From 99cb5530ce1b0fdffd6a1a3919cb12fd38522b34 Mon Sep 17 00:00:00 2001 From: zyp Date: Mon, 20 Nov 2006 14:19:42 +0000 Subject: [project @ zyp-20061120141942-788dd99f008634af] [project @ 67] Fixed bug if missing xattr. --- anidb.py | 2 +- pyanidb/hash.py | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/anidb.py b/anidb.py index 0075a96..b88d8e8 100644 --- a/anidb.py +++ b/anidb.py @@ -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))) -- cgit v1.2.3