Skip to content

Commit e4f9b8b

Browse files
committed
Fix "transferred size and expected total size do not match"
This was caused by the fact that when using diff, the total size was not being calculated correctly - but only gpkgs larger than 10mb (chunk size) were affected MerginMaps/qgis-plugin#142
1 parent 5740846 commit e4f9b8b

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

mergin/client_push.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,12 +140,13 @@ def push_project_async(mc, directory):
140140
# prepare file chunks for upload
141141
for file in upload_files:
142142
file['location'] = mp.fpath_meta(file['diff']['path']) if 'diff' in file else mp.fpath(file['path'])
143+
file_size = file['diff']['size'] if 'diff' in file else file['size']
143144

144145
for chunk_index, chunk_id in enumerate(file["chunks"]):
145-
size = min(UPLOAD_CHUNK_SIZE, file['size'] - chunk_index * UPLOAD_CHUNK_SIZE)
146+
size = min(UPLOAD_CHUNK_SIZE, file_size - chunk_index * UPLOAD_CHUNK_SIZE)
146147
upload_queue_items.append(UploadQueueItem(file['location'], size, transaction_id, chunk_id, chunk_index))
147148

148-
total_size += file['size']
149+
total_size += file_size
149150

150151
job.total_size = total_size
151152
job.upload_queue_items = upload_queue_items
@@ -204,7 +205,9 @@ def push_project_finalize(job):
204205
raise future.exception()
205206

206207
if job.transferred_size != job.total_size:
207-
raise ClientError("Upload error: transferred size and expected total size do not match!")
208+
error_msg = "Transferred size ({}) and expected total size ({}) do not match!".format(job.transferred_size, job.total_size)
209+
job.mp.log.error("--- push finish failed! " + error_msg)
210+
raise ClientError("Upload error: " + error_msg)
208211

209212
if with_upload_of_files:
210213
try:

0 commit comments

Comments
 (0)