aboutsummaryrefslogtreecommitdiff
path: root/gnu/packages/patches/borg-fix-archive-corruption-bug.patch
blob: 0debf119be26335cac0a3e62eeef1b7252216571 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
Fix a bug in `borg check --repair` that corrupts existing archives:

https://github.com/borgbackup/borg/issues/3444

Patches copied from upstream source repository:

https://github.com/borgbackup/borg/commit/e09892caec8a63d59e909518c4e9c230dbd69774
https://github.com/borgbackup/borg/commit/a68d28bfa4db30561150c83eb6a0dca5efa4d9e8

From a68d28bfa4db30561150c83eb6a0dca5efa4d9e8 Mon Sep 17 00:00:00 2001
From: Thomas Waldmann <tw@waldmann-edv.de>
Date: Sat, 16 Dec 2017 01:11:40 +0100
Subject: [PATCH 1/2] modify borg check unit test so it "hangs", see #3444

it doesn't infinitely hang, but slows down considerably.
---
 src/borg/testsuite/archiver.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/borg/testsuite/archiver.py b/src/borg/testsuite/archiver.py
index c7def2c7..b3383e97 100644
--- a/src/borg/testsuite/archiver.py
+++ b/src/borg/testsuite/archiver.py
@@ -3006,7 +3006,7 @@ def test_missing_file_chunk(self):
     def test_missing_archive_item_chunk(self):
         archive, repository = self.open_archive('archive1')
         with repository:
-            repository.delete(archive.metadata.items[-5])
+            repository.delete(archive.metadata.items[0])
             repository.commit()
         self.cmd('check', self.repository_location, exit_code=1)
         self.cmd('check', '--repair', self.repository_location, exit_code=0)
-- 
2.15.1


From e09892caec8a63d59e909518c4e9c230dbd69774 Mon Sep 17 00:00:00 2001
From: Thomas Waldmann <tw@waldmann-edv.de>
Date: Sat, 16 Dec 2017 01:16:05 +0100
Subject: [PATCH 2/2] check --repair: fix malfunctioning validator, fixes #3444

the major problem was the ('path' in item) expression.
the dict has bytes-typed keys there, so it never succeeded as it
looked for a str key. this is a 1.1 regression, 1.0 was fine.

the dict -> StableDict change is just for being more specific,
the check triggered correctly as StableDict subclasses dict,
it was just a bit too general.
---
 src/borg/archive.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/borg/archive.py b/src/borg/archive.py
index 239d00b7..be086800 100644
--- a/src/borg/archive.py
+++ b/src/borg/archive.py
@@ -1457,7 +1457,7 @@ def robust_iterator(archive):
             """
             item_keys = frozenset(key.encode() for key in self.manifest.item_keys)
             required_item_keys = frozenset(key.encode() for key in REQUIRED_ITEM_KEYS)
-            unpacker = RobustUnpacker(lambda item: isinstance(item, dict) and 'path' in item,
+            unpacker = RobustUnpacker(lambda item: isinstance(item, StableDict) and b'path' in item,
                                       self.manifest.item_keys)
             _state = 0
 
-- 
2.15.1