Skip to content

Commit 1cb3051

Browse files
author
PachKosti
committed
fix problem with download files with zero size
relates to issue #80from mergin-plugin
1 parent 8b2a7fb commit 1cb3051

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

mergin/client.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1026,6 +1026,14 @@ def _download_file(self, project_path, file, directory, parallel=True, diff_only
10261026
file_dir = os.path.dirname(os.path.normpath(os.path.join(directory, file['path'])))
10271027
basename = os.path.basename(file['diff']['path']) if diff_only else os.path.basename(file['path'])
10281028

1029+
if file['size'] == 0:
1030+
directory = os.path.abspath(file_dir)
1031+
os.makedirs(directory, exist_ok=True)
1032+
print(os.path.join(file_dir, basename))
1033+
with open(os.path.join(file_dir, basename), 'w'):
1034+
pass
1035+
return file["path"]
1036+
10291037
def download_file_part(part):
10301038
"""Callback to get a part of file using request to server with Range header."""
10311039
start = part * (1 + CHUNK_SIZE)

0 commit comments

Comments
 (0)