Skip to content

Commit fc57d4f

Browse files
committed
remove directory param from _cleanup_failed_download() and do not delete from there
1 parent fb7f371 commit fc57d4f

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

mergin/client_pull.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ def _do_download(item, mc, mp, project_path, job):
104104
job.transferred_size += item.size
105105

106106

107-
def _cleanup_failed_download(directory, mergin_project=None):
107+
def _cleanup_failed_download(mergin_project: MerginProject = None):
108108
"""
109109
If a download job fails, there will be the newly created directory left behind with some
110110
temporary files in it. We want to remove it because a new download would fail because
@@ -126,7 +126,6 @@ def _cleanup_failed_download(directory, mergin_project=None):
126126
dest_path = tmp_file.name
127127
shutil.copyfile(log_file, dest_path)
128128

129-
shutil.rmtree(directory)
130129
return dest_path
131130

132131

@@ -157,7 +156,7 @@ def download_project_async(mc, project_path, directory, project_version=None):
157156
project_info = latest_proj_info
158157

159158
except ClientError:
160-
_cleanup_failed_download(tmp_dir.name, mp)
159+
_cleanup_failed_download(mp)
161160
raise
162161

163162
version = project_info["version"] if project_info["version"] else "v0"
@@ -213,7 +212,7 @@ def download_project_is_running(job):
213212
traceback_lines = traceback.format_exception(type(exc), exc, exc.__traceback__)
214213
job.mp.log.error("Error while downloading project: " + "".join(traceback_lines))
215214
job.mp.log.info("--- download aborted")
216-
job.failure_log_file = _cleanup_failed_download(job.directory.name, job.mp)
215+
job.failure_log_file = _cleanup_failed_download(job.mp)
217216
raise future.exception()
218217
if future.running():
219218
return True
@@ -239,7 +238,7 @@ def download_project_finalize(job):
239238
traceback_lines = traceback.format_exception(type(exc), exc, exc.__traceback__)
240239
job.mp.log.error("Error while downloading project: " + "".join(traceback_lines))
241240
job.mp.log.info("--- download aborted")
242-
job.failure_log_file = _cleanup_failed_download(job.directory.name, job.mp)
241+
job.failure_log_file = _cleanup_failed_download(job.mp)
243242
raise future.exception()
244243

245244
job.mp.log.info("--- download finished")

0 commit comments

Comments
 (0)