fatfsgen.py: omit cluster allocation when the file is empty

This commit is contained in:
Martin Gaňo
2022-09-29 14:54:23 +02:00
parent f33ac0a037
commit 7fb62d41d5
3 changed files with 39 additions and 24 deletions

View File

@@ -69,8 +69,10 @@ def traverse_folder_tree(directory_bytes_: bytes,
entry_position_=i,
lfn_checksum_=lfn_checksum(obj_['DIR_Name'] + obj_['DIR_Name_ext']))
if obj_['DIR_Attr'] == Entry.ATTR_ARCHIVE:
content_ = fat_.get_chained_content(cluster_id_=Entry.get_cluster_id(obj_),
size=obj_['DIR_FileSize'])
content_ = b''
if obj_['DIR_FileSize'] > 0:
content_ = fat_.get_chained_content(cluster_id_=Entry.get_cluster_id(obj_),
size=obj_['DIR_FileSize'])
with open(os.path.join(name, obj_name_), 'wb') as new_file:
new_file.write(content_)
elif obj_['DIR_Attr'] == Entry.ATTR_DIRECTORY: