Skip to content

Commit

Permalink
setup_hash_manager() assume less on arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
niradar committed Jun 17, 2024
1 parent f25b776 commit 9cfb575
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion df_finder3.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def main(args):
fm = setup_file_manager(args)
display_initial_config(args)
confirm_script_execution(args)
hash_manager = setup_hash_manager(args)
hash_manager = setup_hash_manager(args.reference_dir, args.full_hash, args.clear_cache)

duplicates, scan_stats, ref_stats = find_duplicates_files_v3(args, args.scan_dir, args.reference_dir)

Expand Down
14 changes: 8 additions & 6 deletions duplicate_files_in_folders/initializer.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,17 @@ def setup_logging():
logger.addHandler(file_handler)


def setup_hash_manager(args: Namespace):
def setup_hash_manager(reference_dir: str = None, full_hash: bool = False, clear_cache: bool = False):
"""
Setup the hash manager with the reference directory and full hash setting from the arguments.
:param args: the parsed arguments
Setup the hash manager with the given reference directory and full hash setting.
:param reference_dir: the reference directory
:param full_hash: whether to use full hash
:param clear_cache: whether to clear the cache
:return: the hash manager instance
"""
hash_manager = HashManager(reference_dir=args.reference_dir if not detect_pytest() else None,
full_hash=args.full_hash)
if args.clear_cache:
hash_manager = HashManager(reference_dir=reference_dir if not detect_pytest() else None,
full_hash=full_hash)
if clear_cache:
hash_manager.clear_cache()
hash_manager.save_data()
return hash_manager
Expand Down

0 comments on commit 9cfb575

Please sign in to comment.