From 639d60ab3075657a1bf9a7de2c671baeac7256ba Mon Sep 17 00:00:00 2001 From: Andre Kahles Date: Tue, 18 Apr 2023 15:13:42 +0200 Subject: [PATCH] fixed small bug redundantly compressing symlinked files; added test --- archiver/archive.py | 2 +- tests/features/test_integrity.py | 8 ++++++++ .../symlink-archive2/symlink-folder2.part1.lst | 6 ++++++ .../symlink-archive2/symlink-folder2.part1.md5 | 3 +++ .../symlink-folder2.part1.tar.lst | 6 ++++++ .../symlink-archive2/symlink-folder2.part1.tar.lz | Bin 0 -> 599 bytes .../symlink-folder2.part1.tar.lz.md5 | 1 + .../symlink-folder2.part1.tar.md5 | 1 + .../symlink-archive2/symlink-folder2.part2.lst | 4 ++++ .../symlink-archive2/symlink-folder2.part2.md5 | 4 ++++ .../symlink-folder2.part2.tar.lst | 4 ++++ .../symlink-archive2/symlink-folder2.part2.tar.lz | Bin 0 -> 393 bytes .../symlink-folder2.part2.tar.lz.md5 | 1 + .../symlink-folder2.part2.tar.md5 | 1 + .../symlink-archive2/symlink-folder2.parts.txt | 1 + .../symlink-folder2/dir1/file1.txt | 1 + .../symlink-folder2/dir1/file2.txt | 1 + .../symlink-folder2/dir1/file3.txt | 1 + tests/test-ressources/symlink-folder2/dir2/dir1 | 1 + .../symlink-folder2/dir2/file4.txt | 10 ++++++++++ tests/test-ressources/symlink-folder2/file1.txt | 10 ++++++++++ tests/test-ressources/symlink-folder2/file2.txt | 10 ++++++++++ 22 files changed, 75 insertions(+), 1 deletion(-) create mode 100644 tests/test-ressources/symlink-archive2/symlink-folder2.part1.lst create mode 100644 tests/test-ressources/symlink-archive2/symlink-folder2.part1.md5 create mode 100644 tests/test-ressources/symlink-archive2/symlink-folder2.part1.tar.lst create mode 100644 tests/test-ressources/symlink-archive2/symlink-folder2.part1.tar.lz create mode 100644 tests/test-ressources/symlink-archive2/symlink-folder2.part1.tar.lz.md5 create mode 100644 tests/test-ressources/symlink-archive2/symlink-folder2.part1.tar.md5 create mode 100644 tests/test-ressources/symlink-archive2/symlink-folder2.part2.lst create mode 100644 tests/test-ressources/symlink-archive2/symlink-folder2.part2.md5 create mode 100644 tests/test-ressources/symlink-archive2/symlink-folder2.part2.tar.lst create mode 100644 tests/test-ressources/symlink-archive2/symlink-folder2.part2.tar.lz create mode 100644 tests/test-ressources/symlink-archive2/symlink-folder2.part2.tar.lz.md5 create mode 100644 tests/test-ressources/symlink-archive2/symlink-folder2.part2.tar.md5 create mode 100644 tests/test-ressources/symlink-archive2/symlink-folder2.parts.txt create mode 120000 tests/test-ressources/symlink-folder2/dir1/file1.txt create mode 120000 tests/test-ressources/symlink-folder2/dir1/file2.txt create mode 100644 tests/test-ressources/symlink-folder2/dir1/file3.txt create mode 120000 tests/test-ressources/symlink-folder2/dir2/dir1 create mode 100644 tests/test-ressources/symlink-folder2/dir2/file4.txt create mode 100644 tests/test-ressources/symlink-folder2/file1.txt create mode 100644 tests/test-ressources/symlink-folder2/file2.txt diff --git a/archiver/archive.py b/archiver/archive.py index 43d3066..97b5b74 100644 --- a/archiver/archive.py +++ b/archiver/archive.py @@ -153,7 +153,7 @@ def hashes_for_path_list(path_list, source_path_root, max_workers=1): files = [path for path in path_list if (not path.is_dir()) or path.is_symlink()] for path in path_list: - if path.is_dir(): + if path.is_dir() and not path.is_symlink(): files.extend(helpers.get_files_in_folder(path)) return helpers.hash_files_and_check_symlinks(source_path_root, files, max_workers=max_workers) diff --git a/tests/features/test_integrity.py b/tests/features/test_integrity.py index 351f974..b625c7c 100644 --- a/tests/features/test_integrity.py +++ b/tests/features/test_integrity.py @@ -150,6 +150,10 @@ def test_integrity_check_symlink(caplog): assert_successful_shallow_check(archive_file, caplog) +def test_integrity_check_symlink_split_archive(caplog): + archive_dir = get_directory_with_name("symlink-archive2") + + assert_successful_shallow_check(archive_dir, caplog) def test_integrity_check_deep_symlink(caplog): archive_dir = get_directory_with_name("symlink-archive") @@ -160,6 +164,10 @@ def test_integrity_check_deep_symlink(caplog): assert "Symlink symlink-folder/invalid_link_abs found pointing to /not/existing . The archive contains the link itself, but possibly not the file it points to." in caplog.messages assert "Symlink symlink-folder/invalid_link pointing to not_existing is broken in archive" in caplog.messages +def test_integrity_check_deep_symlink_split_archive(caplog): + archive_dir = get_directory_with_name("symlink-archive2") + + assert_successful_deep_check(archive_dir, caplog) def test_verify_relative_symbolic_links(): archive_dir = get_directory_with_name("symlink-archive") diff --git a/tests/test-ressources/symlink-archive2/symlink-folder2.part1.lst b/tests/test-ressources/symlink-archive2/symlink-folder2.part1.lst new file mode 100644 index 0000000..ded8960 --- /dev/null +++ b/tests/test-ressources/symlink-archive2/symlink-folder2.part1.lst @@ -0,0 +1,6 @@ +symlink-folder2/dir2 +symlink-folder2/empty_dir +symlink-folder2/dir1 +symlink-folder2/file2.txt +symlink-folder2/file1.txt +symlink-folder2/dir2/file4.txt diff --git a/tests/test-ressources/symlink-archive2/symlink-folder2.part1.md5 b/tests/test-ressources/symlink-archive2/symlink-folder2.part1.md5 new file mode 100644 index 0000000..a1ad90d --- /dev/null +++ b/tests/test-ressources/symlink-archive2/symlink-folder2.part1.md5 @@ -0,0 +1,3 @@ +ee5d4de881f5e5b962936f884645e0f2 symlink-folder2/dir2/file4.txt +65177efac445439b4c030c95c2aaecb3 symlink-folder2/file1.txt +72ddf5ddde69271a8f6184a6baefcccf symlink-folder2/file2.txt diff --git a/tests/test-ressources/symlink-archive2/symlink-folder2.part1.tar.lst b/tests/test-ressources/symlink-archive2/symlink-folder2.part1.tar.lst new file mode 100644 index 0000000..68c45bb --- /dev/null +++ b/tests/test-ressources/symlink-archive2/symlink-folder2.part1.tar.lst @@ -0,0 +1,6 @@ +drwxr-xr-x 0 akahles staff 0 Mar 29 15:51 symlink-folder2/dir2/ +drwxr-xr-x 0 akahles staff 0 Apr 14 16:18 symlink-folder2/empty_dir/ +drwxr-xr-x 0 akahles staff 0 Mar 29 15:51 symlink-folder2/dir1/ +-rw-r--r-- 0 akahles staff 150 Apr 18 14:34 symlink-folder2/file2.txt +-rw-r--r-- 0 akahles staff 150 Apr 18 14:34 symlink-folder2/file1.txt +-rw-r--r-- 0 akahles staff 150 Apr 14 16:21 symlink-folder2/dir2/file4.txt diff --git a/tests/test-ressources/symlink-archive2/symlink-folder2.part1.tar.lz b/tests/test-ressources/symlink-archive2/symlink-folder2.part1.tar.lz new file mode 100644 index 0000000000000000000000000000000000000000..92c623cb099d69236d02088a412aa63126fddd56 GIT binary patch literal 599 zcmV-d0;v5=T1ij=jsQ8HN#0yAIxe8-$;hmTROQ%sNm@`uJ(bXxG$3M=L+f{v@lc!$ zQV%_SJyHKkU)Ix`U!DU~L=7z-ZFoxs%hiHNS{ z_42_G0eP5`NU-u03IEb&pw7xKZ2lhDR1E?i`KxrT7eNa+6?7Yx`e;g~W4Uev(xQDo z-)`F-!5CNEA6x+9^Zs`Gn~Qi8+oy58GnGmWs|1o)pcdoj-K);7FvBHVNQmlIT$K6^AMSUw)pN5FK)(i9}V-~DNigAM_r68iQF1K4Gwn4JnhI}nC8gCR(D>OHryoW^pE$kI3 z{`P+N5$YYdyPjU&yBjPgDv^jPFY)Zf?N{|$u}fsdBduQ&r1z0Woa(MNltT9b8nc1A zs0J6~FyPKGe= zDlJF)v7N{@K}6|PI^$iZc+|-d(r=AF`|IzHQ{mfy{`W`372M=^Mt=4+^KVhIFuw~( lF`EX0Vuf$RH~)uP1u|Sf%0B=u000000037400000002{l7P$Zb literal 0 HcmV?d00001 diff --git a/tests/test-ressources/symlink-archive2/symlink-folder2.part1.tar.lz.md5 b/tests/test-ressources/symlink-archive2/symlink-folder2.part1.tar.lz.md5 new file mode 100644 index 0000000..ba54e06 --- /dev/null +++ b/tests/test-ressources/symlink-archive2/symlink-folder2.part1.tar.lz.md5 @@ -0,0 +1 @@ +522569e3276005a258cee8a5b4d910cc symlink-folder2.part1.tar.lz diff --git a/tests/test-ressources/symlink-archive2/symlink-folder2.part1.tar.md5 b/tests/test-ressources/symlink-archive2/symlink-folder2.part1.tar.md5 new file mode 100644 index 0000000..7709f49 --- /dev/null +++ b/tests/test-ressources/symlink-archive2/symlink-folder2.part1.tar.md5 @@ -0,0 +1 @@ +8e1adf4389d11b5c6aebb79e49c8e1f7 symlink-folder2.part1.tar diff --git a/tests/test-ressources/symlink-archive2/symlink-folder2.part2.lst b/tests/test-ressources/symlink-archive2/symlink-folder2.part2.lst new file mode 100644 index 0000000..145ce1b --- /dev/null +++ b/tests/test-ressources/symlink-archive2/symlink-folder2.part2.lst @@ -0,0 +1,4 @@ +symlink-folder2/dir2/dir1 +symlink-folder2/dir1/file2.txt +symlink-folder2/dir1/file3.txt +symlink-folder2/dir1/file1.txt diff --git a/tests/test-ressources/symlink-archive2/symlink-folder2.part2.md5 b/tests/test-ressources/symlink-archive2/symlink-folder2.part2.md5 new file mode 100644 index 0000000..96d7f7c --- /dev/null +++ b/tests/test-ressources/symlink-archive2/symlink-folder2.part2.md5 @@ -0,0 +1,4 @@ +21e022b0b2958d0a999060300943ba9a symlink-folder2/dir1/file1.txt +b533fbcd65f0197be9e5c3697f6e268d symlink-folder2/dir1/file2.txt +f55ff17791f929cdf3c1b2a2b412170e symlink-folder2/dir1/file3.txt +d6cbb398634f8799469817abb99ec95e symlink-folder2/dir2/dir1 diff --git a/tests/test-ressources/symlink-archive2/symlink-folder2.part2.tar.lst b/tests/test-ressources/symlink-archive2/symlink-folder2.part2.tar.lst new file mode 100644 index 0000000..a3a2e75 --- /dev/null +++ b/tests/test-ressources/symlink-archive2/symlink-folder2.part2.tar.lst @@ -0,0 +1,4 @@ +lrwxr-xr-x 0 akahles staff 0 Mar 29 15:51 symlink-folder2/dir2/dir1 -> ../dir1 +lrwxr-xr-x 0 akahles staff 0 Mar 29 15:51 symlink-folder2/dir1/file2.txt -> ../file2.txt +-rw-r--r-- 0 akahles staff 15 Mar 29 15:51 symlink-folder2/dir1/file3.txt +lrwxr-xr-x 0 akahles staff 0 Mar 29 15:51 symlink-folder2/dir1/file1.txt -> ../file1.txt diff --git a/tests/test-ressources/symlink-archive2/symlink-folder2.part2.tar.lz b/tests/test-ressources/symlink-archive2/symlink-folder2.part2.tar.lz new file mode 100644 index 0000000000000000000000000000000000000000..8390518311abe7c4034a6ec0a2e2c31c905c79a9 GIT binary patch literal 393 zcmV;40e1dOT1ij=EdV*5N#0yAIxe8-$;hmTROQ%$n^Q~wG)M7cJn5)qr(i$Gs_5xR zn(gl5!TWVFNXgZRkn9<+jkG_?wcEN!u2i~Z-T z^|0kca82gSb=afR-g>*6HM|$2SB=p-9DklgmR7c!cs}y@9l4fSz9H+{bCTVO^^Ebb z>|Cax!>Nh>z#%6cVe=|bugA0cMMscLzh3#SK8Xd3Th9U?yAe0I)VEWFKuyGQBj|9S z%wILN9wT-heI%EjPtNkYP$|IBTE);Wj9NQ)>Jn+&>Tc>0WipU6o#9)8_(rpAzW0@S z&r2