From f5ba641f0c10399c1e153d72df881bb887adf044 Mon Sep 17 00:00:00 2001 From: Patrick Renner Date: Mon, 10 Mar 2025 10:40:51 +0100 Subject: [PATCH] improving performance when verifying 1000s of files (e.g. with create) --- ascmhl/commands.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/ascmhl/commands.py b/ascmhl/commands.py index 824ec07..e168b3b 100644 --- a/ascmhl/commands.py +++ b/ascmhl/commands.py @@ -251,9 +251,13 @@ def create_for_folder_subcommand( file_path = os.path.join(folder_path, item_name) not_found_paths.discard(file_path) for hash_list in existing_history.hash_lists: - for media_hash in hash_list.media_hashes: - if media_hash.path == existing_history.get_relative_file_path(file_path): - break + if detect_renaming: + # this is quite costly, especially for 1000s of files <- the symptom is that the IO becomes slower and slower due to the fs system access for `get_relative_path`` + for media_hash in hash_list.media_hashes: + if media_hash.path == existing_history.get_relative_file_path(file_path): + break + else: + new_paths.add(file_path) else: new_paths.add(file_path) if is_dir: