Skip files with the same hash

This commit is contained in:
LeLuCh B0й 2021-03-21 18:53:52 +07:00 committed by GitHub
parent 572bce21af
commit 0b3555d4c1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -55,7 +55,7 @@ class SaveGameHelper:
epic_id: str = '', cloud_folder: str = '', epic_id: str = '', cloud_folder: str = '',
include_filter: list = None, include_filter: list = None,
exclude_filter: list = None, exclude_filter: list = None,
manifest_dt: datetime = None): manifest_dt: datetime = None, ok_files: dict = None, ok_chunks: set = None):
""" """
:param input_folder: Folder to be packaged into chunks/manifest :param input_folder: Folder to be packaged into chunks/manifest
:param app_name: App name for savegame being stored :param app_name: App name for savegame being stored
@ -104,6 +104,10 @@ class SaveGameHelper:
cur_buffer = None cur_buffer = None
for _file in sorted(files, key=str.casefold): for _file in sorted(files, key=str.casefold):
if ok_files:
if ok_file_manifest := ok_files.get(_file, None):
m.file_manifest_list.elements.append(ok_file_manifest)
continue
s = os.stat(_file) s = os.stat(_file)
f = FileManifest() f = FileManifest()
# get relative path for manifest # get relative path for manifest
@ -146,6 +150,9 @@ class SaveGameHelper:
f.hash = fhash.digest() f.hash = fhash.digest()
m.file_manifest_list.elements.append(f) m.file_manifest_list.elements.append(f)
if ok_chunks:
m.chunk_data_list.elements.extend(ok_chunks)
# write remaining chunk if it exists # write remaining chunk if it exists
if cur_chunk: if cur_chunk:
cur_chunk.data = cur_buffer.getvalue() cur_chunk.data = cur_buffer.getvalue()