thumb clean up notification, call in task

This commit is contained in:
Simon 2024-05-13 18:26:17 +02:00
parent c17627a911
commit 4edb5adead
No known key found for this signature in database
GPG Key ID: 2C15AA5E89985DD4
2 changed files with 30 additions and 1 deletions

View File

@ -366,6 +366,15 @@ class ThumbValidator:
delete_path = os.path.join(folder_path, f"{thumb}.jpg")
os.remove(delete_path)
if to_delete:
message = (
f"[thumbs][video][{video_folder}] "
+ f"delete {len(to_delete)} unused thumbnails"
)
print(message)
if self.task:
self.task.send_progress([message])
@staticmethod
def _get_vid_thumbs_should(video_folder: str) -> set[str]:
"""get indexed"""
@ -393,6 +402,15 @@ class ThumbValidator:
delete_path = os.path.join(channel_dir, channel_thumb)
os.remove(delete_path)
if to_delete:
message = (
"[thumbs][channel] "
+ f"delete {len(to_delete)} unused channel art"
)
print(message)
if self.task:
self.task.send_progress([message])
def _clean_up_playlists(self):
"""clean up unneeded playlist thumbs"""
playlist_dir = os.path.join(EnvironmentSettings.CACHE_DIR, "playlists")
@ -403,6 +421,15 @@ class ThumbValidator:
delete_path = os.path.join(playlist_dir, f"{playlist_id}.jpg")
os.remove(delete_path)
if to_delete:
message = (
"[thumbs][playlist] "
+ f"delete {len(to_delete)} unused playlist art"
)
print(message)
if self.task:
self.task.send_progress([message])
@staticmethod
def _get_total(index_name):
"""get total documents in index"""

View File

@ -259,7 +259,9 @@ def thumbnail_check(self):
return
manager.init(self)
ThumbValidator(task=self).validate()
thumnail = ThumbValidator(task=self)
thumnail.validate()
thumnail.clean_up()
@shared_task(bind=True, name="resync_thumbs", base=BaseTask)