Skip to content

Commit 82413f1

Browse files
author
Andrei Neagu
committed
refactor
1 parent abc45ef commit 82413f1

File tree

1 file changed

+11
-19
lines changed
  • services/dynamic-sidecar/src/simcore_service_dynamic_sidecar/modules

1 file changed

+11
-19
lines changed

services/dynamic-sidecar/src/simcore_service_dynamic_sidecar/modules/nodeports.py

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import json
22
import logging
33
import os
4-
import shutil
54
import sys
65
import time
76
from asyncio import CancelledError
@@ -12,7 +11,6 @@
1211
from pathlib import Path
1312
from typing import cast
1413

15-
import aiofiles.os
1614
import magic
1715
from aiofiles.tempfile import TemporaryDirectory as AioTemporaryDirectory
1816
from models_library.basic_types import IDStr
@@ -22,7 +20,7 @@
2220
from pydantic import ByteSize, TypeAdapter
2321
from servicelib.archiving_utils import PrunableFolder, archive_dir, unarchive_dir
2422
from servicelib.async_utils import run_sequentially_in_context
25-
from servicelib.file_utils import remove_directory
23+
from servicelib.file_utils import remove_directory, shutil_move
2624
from servicelib.logging_utils import log_context
2725
from servicelib.progress_bar import ProgressBarData
2826
from servicelib.utils import limited_gather
@@ -239,19 +237,6 @@ def _is_zip_file(file_path: Path) -> bool:
239237
return f"{mime_type}" == "application/zip"
240238

241239

242-
_shutil_move = aiofiles.os.wrap(shutil.move)
243-
244-
245-
async def _move_archive(final_path: Path, archive_path: Path) -> set[Path]:
246-
final_path = final_path / archive_path.name
247-
248-
with log_context(_logger, logging.DEBUG, f"moving {archive_path} to {final_path}"):
249-
final_path.parent.mkdir(exist_ok=True, parents=True)
250-
await _shutil_move(archive_path, final_path)
251-
252-
return {final_path}
253-
254-
255240
async def _get_data_from_port(
256241
port: Port, *, target_dir: Path, progress_bar: ProgressBarData
257242
) -> tuple[Port, ItemConcreteValue | None, ByteSize]:
@@ -297,9 +282,16 @@ async def _get_data_from_port(
297282
progress_bar=sub_progress,
298283
)
299284
else:
300-
archive_files: set[Path] = await _move_archive(
301-
final_path, downloaded_file
302-
)
285+
# move archive to directory as is
286+
final_path = final_path / downloaded_file.name
287+
288+
with log_context(
289+
_logger, logging.DEBUG, f"moving {downloaded_file} to {final_path}"
290+
):
291+
final_path.parent.mkdir(exist_ok=True, parents=True)
292+
await shutil_move(downloaded_file, final_path)
293+
294+
archive_files: set[Path] = {final_path}
303295

304296
# NOTE: after the port content changes, make sure old files
305297
# which are no longer part of the port, are removed

0 commit comments

Comments
 (0)