Commit b09bbed
Archive.delete: don't reuse msgpack Unpacker after an unpacking failure
msgpack does not support reusing an Unpacker instance after an unpacking
failure - a new instance must be created instead.
In the forced-delete path, item metadata was unpacked via "for item in
unpacker" with an "except (TypeError, ValueError)" handler. msgpack's
FormatError/StackError are ValueError subclasses, so a real unpacking
failure was caught there and the (now broken) unpacker kept being reused
for the following chunks, making them all fail too - leaking their chunk
references.
Restructure the loop to use next(unpacker) so each failure mode gets a
tight handler:
- StopIteration: buffer drained, feed next chunk
- msgpack.UnpackException: corruption; in forced mode replace the unpacker
with a fresh instance and skip the rest of the chunk
- TypeError/ValueError: only wraps Item processing (bad types yielded)
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>1 parent 8abdd3b commit b09bbed
1 file changed
Lines changed: 22 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1035 | 1035 | | |
1036 | 1036 | | |
1037 | 1037 | | |
1038 | | - | |
1039 | | - | |
| 1038 | + | |
| 1039 | + | |
| 1040 | + | |
| 1041 | + | |
| 1042 | + | |
| 1043 | + | |
| 1044 | + | |
| 1045 | + | |
| 1046 | + | |
| 1047 | + | |
| 1048 | + | |
| 1049 | + | |
| 1050 | + | |
| 1051 | + | |
| 1052 | + | |
1040 | 1053 | | |
1041 | 1054 | | |
1042 | 1055 | | |
1043 | 1056 | | |
1044 | 1057 | | |
1045 | | - | |
1046 | | - | |
1047 | | - | |
1048 | | - | |
1049 | | - | |
1050 | | - | |
| 1058 | + | |
| 1059 | + | |
| 1060 | + | |
| 1061 | + | |
| 1062 | + | |
| 1063 | + | |
1051 | 1064 | | |
1052 | 1065 | | |
1053 | | - | |
| 1066 | + | |
1054 | 1067 | | |
1055 | 1068 | | |
1056 | 1069 | | |
| |||
0 commit comments