[ui] thumbnails: fallback if thumbnailDir could not be created

This commit is contained in:
Loïc Vital 2023-06-14 18:27:58 +02:00
parent 0c137a141f
commit aca308dbf9

View file

@ -89,7 +89,11 @@ class ThumbnailCache(QObject):
ThumbnailCache.cleaningThread.start()
# Make sure the thumbnail directory exists before writing into it
os.makedirs(ThumbnailCache.thumbnailDir, exist_ok=True)
try:
os.makedirs(ThumbnailCache.thumbnailDir, exist_ok=True)
except OSError:
logging.warning(f'[ThumbnailCache] Failed to create directory: {ThumbnailCache.thumbnailDir}')
pass
@staticmethod
def clean():
@ -218,6 +222,9 @@ class ThumbnailCache(QObject):
if not imgSource.isValid():
return None
if not os.path.exists(ThumbnailCache.thumbnailDir):
return imgSource
imgPath = imgSource.toLocalFile()
path = ThumbnailCache.thumbnailPath(imgPath)