Skip to content

Commit f45af09

Browse files
committed
download items to temp directory to avoid issues
1 parent 9769f63 commit f45af09

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

mergin/client_pull.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,11 +164,13 @@ def download_project_async(mc, project_path, directory, project_version=None):
164164

165165
mp.log.info(f"got project info. version {version}")
166166

167+
tmp_dir = tempfile.TemporaryDirectory(prefix="python-api-client-")
168+
167169
# prepare download
168170
update_tasks = [] # stuff to do at the end of download
169171
for file in project_info["files"]:
170172
file["version"] = version
171-
items = _download_items(file, directory)
173+
items = _download_items(file, tmp_dir.name)
172174
is_latest_version = project_version == latest_proj_info["version"]
173175
update_tasks.append(UpdateTask(file["path"], items, latest_version=is_latest_version))
174176

@@ -182,7 +184,9 @@ def download_project_async(mc, project_path, directory, project_version=None):
182184

183185
mp.log.info(f"will download {len(update_tasks)} files in {len(download_list)} chunks, total size {total_size}")
184186

185-
job = DownloadJob(project_path, total_size, version, update_tasks, download_list, directory, mp, project_info)
187+
job = DownloadJob(
188+
project_path, total_size, version, update_tasks, download_list, directory, mp, project_info, tmp_dir
189+
)
186190

187191
# start download
188192
job.executor = concurrent.futures.ThreadPoolExecutor(max_workers=4)

0 commit comments

Comments
 (0)