Skip to content

Commit 5bfbfac

Browse files
Merge pull request #9790 from ThomasWaldmann/support-msgpack121-1.4
support msgpack 1.2.1
2 parents 382f27c + b09bbed commit 5bfbfac

4 files changed

Lines changed: 25 additions & 12 deletions

File tree

docs/changes.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -473,7 +473,7 @@ Note: Many of the fixed issues listed below relate to rather rare or theoretical
473473

474474
Other changes:
475475

476-
- msgpack: allow 1.2.0
476+
- msgpack: also allow 1.2.0 and 1.2.1
477477
- use F_FULLFSYNC on macOS for SyncFile data durability, #9383
478478
- mount: improve error msg when uid/gid cannot be resolved, #9574
479479
- docs:

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ dependencies = [
3535
# Please note:
3636
# Using any other msgpack version is not supported by Borg development and
3737
# any feedback related to issues caused by this will be ignored.
38-
"msgpack >=1.0.3, <=1.2.0",
38+
"msgpack >=1.0.3, <=1.2.1",
3939
"packaging",
4040
]
4141

src/borg/archive.py

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1035,22 +1035,35 @@ def chunk_decref(id, stats, part=False):
10351035
data = self.key.decrypt(items_id, data)
10361036
unpacker.feed(data)
10371037
chunk_decref(items_id, stats)
1038-
try:
1039-
for item in unpacker:
1038+
while True:
1039+
try:
1040+
item = next(unpacker)
1041+
except StopIteration:
1042+
# no more (complete) items in the buffer, feed the next chunk
1043+
break
1044+
except msgpack.UnpackException:
1045+
# items metadata corrupted. the unpacker can't be reused after an
1046+
# unpacking failure, so create a fresh one and skip the rest of this chunk.
1047+
if forced == 0:
1048+
raise
1049+
error = True
1050+
unpacker = msgpack.Unpacker(use_list=False)
1051+
break
1052+
try:
10401053
item = Item(internal_dict=item)
10411054
if 'chunks' in item:
10421055
part = not self.consider_part_files and 'part' in item
10431056
for chunk_id, size, csize in item.chunks:
10441057
chunk_decref(chunk_id, stats, part=part)
1045-
except (TypeError, ValueError):
1046-
# if items metadata spans multiple chunks and one chunk got dropped somehow,
1047-
# it could be that unpacker yields bad types
1048-
if forced == 0:
1049-
raise
1050-
error = True
1058+
except (TypeError, ValueError):
1059+
# if items metadata spans multiple chunks and one chunk got dropped somehow,
1060+
# it could be that unpacker yields bad types
1061+
if forced == 0:
1062+
raise
1063+
error = True
10511064
if progress:
10521065
pi.finish()
1053-
except (msgpack.UnpackException, Repository.ObjectNotFound):
1066+
except Repository.ObjectNotFound:
10541067
# items metadata corrupted
10551068
if forced == 0:
10561069
raise

src/borg/helpers/msgpack.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ def is_supported_msgpack():
145145
version_check = os.environ.get('BORG_MSGPACK_VERSION_CHECK', 'yes').strip().lower()
146146

147147
return version_check == 'no' or (
148-
(1, 0, 3) <= msgpack.version[:3] <= (1, 2, 0) and
148+
(1, 0, 3) <= msgpack.version[:3] <= (1, 2, 1) and
149149
msgpack.version not in []
150150
)
151151

0 commit comments

Comments
 (0)