Skip to content

Commit

Permalink
fixed small bug redundantly compressing symlinked files; added test
Browse files Browse the repository at this point in the history
  • Loading branch information
akahles committed Apr 18, 2023
1 parent 193eba8 commit 639d60a
Show file tree
Hide file tree
Showing 22 changed files with 75 additions and 1 deletion.
2 changes: 1 addition & 1 deletion archiver/archive.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 8 additions & 0 deletions tests/features/test_integrity.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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")
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
ee5d4de881f5e5b962936f884645e0f2 symlink-folder2/dir2/file4.txt
65177efac445439b4c030c95c2aaecb3 symlink-folder2/file1.txt
72ddf5ddde69271a8f6184a6baefcccf symlink-folder2/file2.txt
Original file line number Diff line number Diff line change
@@ -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
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
522569e3276005a258cee8a5b4d910cc symlink-folder2.part1.tar.lz
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
8e1adf4389d11b5c6aebb79e49c8e1f7 symlink-folder2.part1.tar
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
symlink-folder2/dir2/dir1
symlink-folder2/dir1/file2.txt
symlink-folder2/dir1/file3.txt
symlink-folder2/dir1/file1.txt
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
a88baeed62e4ad8777f29a611b66c034 symlink-folder2.part2.tar.lz
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
c42632d7622a85ced4d96cd8937280af symlink-folder2.part2.tar
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2
1 change: 1 addition & 0 deletions tests/test-ressources/symlink-folder2/dir1/file1.txt
1 change: 1 addition & 0 deletions tests/test-ressources/symlink-folder2/dir1/file2.txt
1 change: 1 addition & 0 deletions tests/test-ressources/symlink-folder2/dir1/file3.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
File 3 content
1 change: 1 addition & 0 deletions tests/test-ressources/symlink-folder2/dir2/dir1
10 changes: 10 additions & 0 deletions tests/test-ressources/symlink-folder2/dir2/file4.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
File 4 content
File 4 content
File 4 content
File 4 content
File 4 content
File 4 content
File 4 content
File 4 content
File 4 content
File 4 content
10 changes: 10 additions & 0 deletions tests/test-ressources/symlink-folder2/file1.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
File 1 content
File 1 content
File 1 content
File 1 content
File 1 content
File 1 content
File 1 content
File 1 content
File 1 content
File 1 content
10 changes: 10 additions & 0 deletions tests/test-ressources/symlink-folder2/file2.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
File 2 content
File 2 content
File 2 content
File 2 content
File 2 content
File 2 content
File 2 content
File 2 content
File 2 content
File 2 content

0 comments on commit 639d60a

Please sign in to comment.