1
0
mirror of https://github.com/openSUSE/osc.git synced 2024-11-09 22:36:14 +01:00

Fix object has no attribute 'dataoff'

`ext_fnhdr` exists only if call `_appendHdr()` once found a very long file name. Without that, impossible to get `ext_fnhdr_data`. It should be safe to leave `ext_fnhdr_data` as None if no `ext_fnhdr` added since later every `hdrs` will be checked for very long file name and if none of them will meet the condition, `ext_fnhdr_data` is not needed at all.
This commit is contained in:
ila 2024-08-16 01:26:16 +04:00 committed by Daniel Mach
parent 735bab7de2
commit d80a3b7457

View File

@ -147,8 +147,10 @@ class Ar:
"""
# read extended header with long file names and then only seek into the right offsets
self.__file.seek(self.ext_fnhdr.dataoff, os.SEEK_SET)
ext_fnhdr_data = self.__file.read(self.ext_fnhdr.size)
ext_fnhdr_data = None
if self.ext_fnhdr:
self.__file.seek(self.ext_fnhdr.dataoff, os.SEEK_SET)
ext_fnhdr_data = self.__file.read(self.ext_fnhdr.size)
for h in self.hdrs:
if h.file == b'/':
@ -161,6 +163,7 @@ class Ar:
# long file name
assert h.file[0:1] == b"/"
assert ext_fnhdr_data is not None
start = int(h.file[1:])
end = ext_fnhdr_data.find(b'/', start)