diff --git a/deduplify/_version.py b/deduplify/_version.py index f72802b..c1154e4 100644 --- a/deduplify/_version.py +++ b/deduplify/_version.py @@ -7,5 +7,5 @@ from incremental import Version -__version__ = Version("deduplify", 0, 1, 4) +__version__ = Version("deduplify", 0, 1, 5) __all__ = ["__version__"] diff --git a/deduplify/compare_files.py b/deduplify/compare_files.py index 159e915..82cdf1b 100644 --- a/deduplify/compare_files.py +++ b/deduplify/compare_files.py @@ -66,6 +66,11 @@ def compare_filenames(file_list: list) -> str: if len(name_freq) == 1: file_list.remove(min(file_list, key=len)) return file_list + elif (len(name_freq) > 1) and (list(set(file_list)) == 1): + # there are multiple filepaths that are different, + # but by coincidence have the same length + file_list = file_list.sort() + file_list.remove(file_list[1:]) else: raise ValueError( f"The following filenames need investigation.\n{name_freq}\n{file_list}" diff --git a/tests/test_compare.py b/tests/test_compare.py index 6c841e8..f4628eb 100644 --- a/tests/test_compare.py +++ b/tests/test_compare.py @@ -28,6 +28,18 @@ def test_compare_filenames(): assert out_file_list == ["different/path/to/test/file.txt"] +def test_compare_filenames_same_length(): + test_file_list = [ + "path/to/test/file.txt", + "diff/xy/path/file.txt", + ] + + out_file_list = compare_filenames(test_file_list) + + assert len(out_file_list) == 1 + assert out_file_list == ["path/to/test/file.txt"] + + @patch("deduplify.compare_files.os.remove") def test_delete_files(mock): test_files = ["path/to/file_1.txt", "path/to/file_2.txt"]