diff --git a/libsaria/storage/cache.py b/libsaria/storage/cache.py index 17a15f61..fa2036de 100644 --- a/libsaria/storage/cache.py +++ b/libsaria/storage/cache.py @@ -17,6 +17,11 @@ def file_exists(cache_path): return False return getsize(cache_path) != 0 +def file_empty(cache_path): + if not isfile(cache_path): + return False + return getsize(cache_path) == 0 + def make_cache_path(artist, album, file): cache_file = "%s%s%s%s" % (artist, sep, album, sep) cache_path = join(CACHE_DIR, cache_file) @@ -28,7 +33,7 @@ def fill_cache(artist, album, title, cache_func, cache_path): f = open(cache_path, 'w') cache_func(artist, album, title, f) f.close() - if not file_exists(cache_path): + if file_empty(cache_path): os.remove(cache_path) return None return cache_path