Skip to content

Commit 25498d4

Browse files
Revert "Add files via upload"
This reverts commit 6fefa0d.
1 parent 6fefa0d commit 25498d4

File tree

1 file changed

+10
-16
lines changed

1 file changed

+10
-16
lines changed

pyneofile.py

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -93,16 +93,18 @@ def _normalize_algo(algo):
9393
return 'auto'
9494
return a
9595

96-
def _normalize_ver_digits(ver):
96+
def _normalize_ver_digits(ver_text):
9797
"""
98-
Accepts '001', '1', or int-like; returns a canonical zero-padded string
99-
(e.g., '001'). Adjust this to whatever your writer emits in the global header.
98+
Make the on-disk version match Archive's strict header check:
99+
- remove dots
100+
- strip leading zeros by int() cast when numeric
101+
Falls back to the raw digits if not purely numeric.
100102
"""
101-
if ver is None:
102-
return "001"
103-
s = str(ver).replace('.', '')
104-
# If your header stores zero-padded 3 digits, enforce that here:
105-
return "{:0>3}".format(int(s)) if s.isdigit() else s
103+
raw = ver_text.replace(".", "")
104+
try:
105+
return str(int(raw)) # "001" -> "1"
106+
except ValueError:
107+
return raw # keep as-is if not numeric
106108

107109
def _compress_bytes(data, algo='none', level=None):
108110
"""Return (stored_bytes, used_algo)."""
@@ -694,14 +696,6 @@ def _parse_global_header(fp, formatspecs, skipchecksum=False):
694696
checksumtype = _read_cstring(fp, delim).decode('UTF-8')
695697
_header_cs = _read_cstring(fp, delim).decode('UTF-8')
696698
return {'fencoding': fencoding, 'fnumfiles': fnumfiles, 'fostype': fostype,
697-
# --- Strict check for magic+version against formatspecs ---
698-
exp_magic = formatspecs.get('format_magic', '')
699-
exp_ver = _normalize_ver_digits(_ver_digits(formatspecs.get('format_ver', '001')))
700-
expected_magicver = exp_magic + exp_ver
701-
if str(magicver) != str(expected_magicver):
702-
raise ValueError(
703-
"Bad archive header: magic/version mismatch (got {!r}, expected {!r})".format(magicver, expected_magicver)
704-
)
705699
'fextradata': extras, 'fchecksumtype': checksumtype,
706700
'ffilelist': [], 'fformatspecs': formatspecs}
707701

0 commit comments

Comments
 (0)