From 01beee37a7902fc7674519562238b8e20f95bfe3 Mon Sep 17 00:00:00 2001 From: Thomas Waldmann Date: Sat, 17 Mar 2018 18:24:55 +0100 Subject: [PATCH 1/2] add test for issue #3688 (cherry picked from commit 0a46d3330c468b125e7302e3b0b61c0577672464) --- src/borg/testsuite/archiver.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/borg/testsuite/archiver.py b/src/borg/testsuite/archiver.py index 52f38c357..54a63acd4 100644 --- a/src/borg/testsuite/archiver.py +++ b/src/borg/testsuite/archiver.py @@ -3410,6 +3410,7 @@ def test_basic_functionality(self): # Setup files for the second snapshot self.create_regular_file('file_added', size=2048) + self.create_regular_file('file_empty_added', size=0) os.unlink('input/file_removed') os.unlink('input/file_removed2') os.unlink('input/file_replaced') @@ -3484,6 +3485,9 @@ def do_asserts(output, can_compare_ids): if are_hardlinks_supported(): assert 'added 2.05 kB input/hardlink_added' in output + # check if a diff between non-existent and empty new file is found + assert 'added 0 B input/file_empty_added' in output + # The inode has two links and both of them are deleted. They should # appear as two deleted files. assert 'removed 256 B input/file_removed' in output From c3b7d7b60cc3fe597e0f338572a0458922e1aca4 Mon Sep 17 00:00:00 2001 From: Thomas Waldmann Date: Sat, 17 Mar 2018 18:50:51 +0100 Subject: [PATCH 2/2] consider an empty file as different to a non-existing file, fixes #3688 --- src/borg/archiver.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/borg/archiver.py b/src/borg/archiver.py index 7a5cedb20..1435dd827 100644 --- a/src/borg/archiver.py +++ b/src/borg/archiver.py @@ -1030,6 +1030,10 @@ def compare_link(item1, item2): return 'changed link' def contents_changed(item1, item2): + if item1.get('deleted') != item2.get('deleted'): + # a deleleted/non-existing file is considered different to an existing file, + # even if the latter is empty. + return True if can_compare_chunk_ids: return item1.chunks != item2.chunks else: