summaryrefslogtreecommitdiff
path: root/raphodo/cache.py
diff options
context:
space:
mode:
Diffstat (limited to 'raphodo/cache.py')
-rw-r--r--raphodo/cache.py17
1 files changed, 10 insertions, 7 deletions
diff --git a/raphodo/cache.py b/raphodo/cache.py
index 0801762..92e7464 100644
--- a/raphodo/cache.py
+++ b/raphodo/cache.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python3
-# Copyright (C) 2015-2017 Damon Lynch <damonlynch@gmail.com>
+# Copyright (C) 2015-2018 Damon Lynch <damonlynch@gmail.com>
# This file is part of Rapid Photo Downloader.
#
@@ -47,7 +47,7 @@ http://specifications.freedesktop.org/thumbnail-spec/thumbnail-spec-latest.html
"""
__author__ = 'Damon Lynch'
-__copyright__ = "Copyright 2015-2017, Damon Lynch"
+__copyright__ = "Copyright 2015-2018, Damon Lynch"
import os
import sys
@@ -69,8 +69,7 @@ from raphodo.rpdsql import CacheSQL
GetThumbnail = namedtuple('GetThumbnail', 'disk_status, thumbnail, path')
-GetThumbnailPath = namedtuple('GetThumbnailPath', 'disk_status, path, mdatatime, '
- 'orientation_unknown')
+GetThumbnailPath = namedtuple('GetThumbnailPath', 'disk_status, path, mdatatime, orientation_unknown')
class MD5Name:
"""Generate MD5 hashes for file names."""
@@ -521,9 +520,13 @@ class ThumbnailCacheSql:
os.remove(thumbnail)
deleted_thumbnails.append(name)
if len(deleted_thumbnails):
- self.thumb_db.delete_thumbnails(deleted_thumbnails)
- logging.debug('Deleted {} thumbnail files that had not been '
- 'accessed for {} or more days'.format(len(deleted_thumbnails), days))
+ if self.thumb_db.cache_exists():
+ self.thumb_db.delete_thumbnails(deleted_thumbnails)
+ logging.debug(
+ 'Deleted {} thumbnail files that had not been accessed for {} or more days'.format(
+ len(deleted_thumbnails), days
+ )
+ )
def purge_cache(self) -> None:
"""