diff --git a/ascmhl/commands.py b/ascmhl/commands.py index 4003292..5ae08ca 100644 --- a/ascmhl/commands.py +++ b/ascmhl/commands.py @@ -232,7 +232,7 @@ def create_for_folder_subcommand( # we collect all paths we expect to find first and remove every path that we actually found while # traversing the file system, so this set will at the end contain the file paths not found in the file system - not_found_paths = existing_history.set_of_file_paths() + not_found_paths = existing_history.set_of_file_paths(potential_windows_paths=convert_windows_paths) renamed_files = existing_history.renamed_path_with_previous_path() not_found_paths = {p if renamed_files.get(p, None) is None else renamed_files[p] for p in not_found_paths} new_paths = set() diff --git a/ascmhl/hashlist.py b/ascmhl/hashlist.py index 642b19f..bdbb81b 100644 --- a/ascmhl/hashlist.py +++ b/ascmhl/hashlist.py @@ -11,6 +11,7 @@ from typing import List, Dict, Optional, Set from datetime import datetime import os +from pathlib import Path from . import logger from .ignore import MHLIgnoreSpec @@ -76,10 +77,13 @@ def find_or_create_media_hash_for_path(self, relative_path, file_size, file_modi self.append_hash(media_hash) return media_hash - def set_of_file_paths(self, root_path) -> Set[str]: + def set_of_file_paths(self, root_path, potential_windows_paths=False) -> Set[str]: all_paths = set() for media_hash in self.media_hashes: - all_paths.add(os.path.join(root_path, media_hash.path)) + media_path = media_hash.path + if potential_windows_paths: + media_path = Path(media_path).as_posix() + all_paths.add(os.path.join(root_path, media_path)) return all_paths def renamed_path_with_previous_path(self, root_path): diff --git a/ascmhl/history.py b/ascmhl/history.py index 5a0024f..ce26fb2 100644 --- a/ascmhl/history.py +++ b/ascmhl/history.py @@ -189,10 +189,12 @@ def find_history_for_path(self, relative_path: str) -> Tuple[MHLHistory, str]: dir_path = os.path.dirname(dir_path) return self, relative_path - def set_of_file_paths(self) -> Set[str]: + def set_of_file_paths(self, potential_windows_paths=False) -> Set[str]: all_paths = set() for hash_list in self.hash_lists: - all_paths.update(hash_list.set_of_file_paths(self.get_root_path())) + all_paths.update( + hash_list.set_of_file_paths(self.get_root_path(), potential_windows_paths=potential_windows_paths) + ) for child_history in self.child_histories: all_paths.update(child_history.set_of_file_paths()) return all_paths