summaryrefslogtreecommitdiff
path: root/raphodo/cache.py
diff options
context:
space:
mode:
authorAntoine Beaupré <anarcat@debian.org>2018-07-30 10:50:17 -0400
committerAntoine Beaupré <anarcat@debian.org>2018-07-30 10:50:17 -0400
commitbaec34cc51c5822c002b22072a9e99d662dce465 (patch)
tree4398591203334f0a028d2395786e3717d9e38e1d /raphodo/cache.py
parent0a297829eaf3912c939e1b43a3ef6ddeb7607b38 (diff)
New upstream version 0.9.10upstream/0.9.10
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:
"""