mirror of
https://github.com/derrod/legendary.git
synced 2024-12-22 01:45:28 +00:00
[core] Show warnings and error out if save data is corrupted
This commit is contained in:
parent
d5ec14b556
commit
85a275950d
|
@ -807,6 +807,10 @@ class LegendaryCore:
|
|||
cpath_p = fname.split('/', 3)[:3]
|
||||
cpath_p.append(chunk.path)
|
||||
cpath = '/'.join(cpath_p)
|
||||
if cpath not in files:
|
||||
self.log.warning(f'Chunk {cpath} not in file list, save data may be incomplete!')
|
||||
continue
|
||||
|
||||
self.log.debug(f'Downloading chunk "{cpath}"')
|
||||
r = self.egs.unauth_session.get(files[cpath]['readLink'])
|
||||
if r.status_code != 200:
|
||||
|
@ -815,6 +819,14 @@ class LegendaryCore:
|
|||
c = Chunk.read_buffer(r.content)
|
||||
chunks[c.guid_num] = c.data
|
||||
|
||||
if not chunks:
|
||||
if manifest_name:
|
||||
self.log.fatal(f'No chunks were available, aborting.')
|
||||
return
|
||||
else:
|
||||
self.log.error(f'No chunks were available, skipping.')
|
||||
continue
|
||||
|
||||
for fm in m.file_manifest_list.elements:
|
||||
dirs, fname = os.path.split(fm.filename)
|
||||
fdir = os.path.join(_save_dir, dirs)
|
||||
|
@ -825,6 +837,9 @@ class LegendaryCore:
|
|||
self.log.debug(f'Writing "{fpath}"...')
|
||||
with open(fpath, 'wb') as fh:
|
||||
for cp in fm.chunk_parts:
|
||||
if cp.guid_num not in chunks:
|
||||
self.log.error(f'Chunk part for {fname} is missing, file may be corrupted!')
|
||||
else:
|
||||
fh.write(chunks[cp.guid_num][cp.offset:cp.offset + cp.size])
|
||||
|
||||
# set modified time to savegame creation timestamp
|
||||
|
|
Loading…
Reference in a new issue