From 78bd153158d69268b190028a3a4bf1a87bc23a25 Mon Sep 17 00:00:00 2001 From: tcely Date: Fri, 28 Mar 2025 00:26:33 -0400 Subject: [PATCH] Delete the source only when it was found --- tubesync/sync/tasks.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tubesync/sync/tasks.py b/tubesync/sync/tasks.py index 59faa7c9..679c8b75 100644 --- a/tubesync/sync/tasks.py +++ b/tubesync/sync/tasks.py @@ -792,8 +792,9 @@ def delete_all_media_for_source(source_id, source_name, source_directory): (source and source.delete_removed_media) or (directory_path / '.to_be_removed').is_file() ) - with atomic(durable=True): - source.delete() + if source: + with atomic(durable=True): + source.delete() if remove: log.info(f'Deleting directory for: {source_name}: {directory_path}') rmtree(directory_path, True)