From 7a9455db88884571faef1f17044003c4e6460836 Mon Sep 17 00:00:00 2001 From: Rodos Date: Fri, 14 Nov 2025 10:17:08 +1100 Subject: [PATCH] fix: Prevent duplicate attachment downloads Fixes bug where attachments were downloaded multiple times with incremented filenames (file.mov, file_1.mov, file_2.mov) when running backups without --skip-existing flag. I should not have used the --skip-existing flag for attachments, it did not do what I thought it did. The correct approach is to always use the manifest to guide what has already been downloaded and what now needs to be done. --- github_backup/github_backup.py | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/github_backup/github_backup.py b/github_backup/github_backup.py index b0c2aef..d1828d0 100644 --- a/github_backup/github_backup.py +++ b/github_backup/github_backup.py @@ -919,12 +919,6 @@ def download_attachment_file(url, path, auth, as_app=False, fine=False): "error": None, } - if os.path.exists(path): - metadata["success"] = True - metadata["http_status"] = 200 # Assume success if already exists - metadata["size_bytes"] = os.path.getsize(path) - return metadata - # Create simple request (no API query params) request = Request(url) request.add_header("Accept", "application/octet-stream") @@ -1337,10 +1331,10 @@ def download_attachments( attachments_dir = os.path.join(item_cwd, "attachments", str(number)) manifest_path = os.path.join(attachments_dir, "manifest.json") - # Load existing manifest if skip_existing is enabled + # Load existing manifest to prevent duplicate downloads existing_urls = set() existing_metadata = [] - if args.skip_existing and os.path.exists(manifest_path): + if os.path.exists(manifest_path): try: with open(manifest_path, "r") as f: existing_manifest = json.load(f) @@ -1395,9 +1389,6 @@ def download_attachments( filename = get_attachment_filename(url) filepath = os.path.join(attachments_dir, filename) - # Check for collision BEFORE downloading - filepath = resolve_filename_collision(filepath) - # Download and get metadata metadata = download_attachment_file( url,