feat: feedback verbetering 05
This commit is contained in:
Binary file not shown.
Binary file not shown.
@@ -95,10 +95,11 @@ class MoveTaskService:
|
||||
)
|
||||
|
||||
root_alias = next(iter(source_aliases))
|
||||
if root_alias != resolved_destination_base.alias:
|
||||
has_directory = any(resolved_source.absolute.is_dir() for resolved_source in resolved_sources)
|
||||
if root_alias != resolved_destination_base.alias and has_directory:
|
||||
raise AppError(
|
||||
code="invalid_request",
|
||||
message="Cross-root batch directory move is not supported in v1",
|
||||
message="Cross-root batch move with directories is not supported in v1",
|
||||
status_code=400,
|
||||
details={"destination_base": destination_base},
|
||||
)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import errno
|
||||
import os
|
||||
import shutil
|
||||
import threading
|
||||
@@ -355,7 +356,13 @@ class TaskRunner:
|
||||
completed_items = self._move_directory_item(task_id, item, completed_items, total_items)
|
||||
else:
|
||||
file_entry = self._file_entries(item)[0]
|
||||
completed_items = self._move_single_planned_file(task_id, file_entry, completed_items, total_items)
|
||||
completed_items = self._move_single_planned_file(
|
||||
task_id,
|
||||
file_entry,
|
||||
completed_items,
|
||||
total_items,
|
||||
same_root=bool(item.get("same_root", True)),
|
||||
)
|
||||
if self._is_cancel_requested(task_id):
|
||||
self._finalize_cancelled(task_id, done_items=completed_items, total_items=total_items)
|
||||
return
|
||||
@@ -631,6 +638,8 @@ class TaskRunner:
|
||||
file_entry: dict[str, str],
|
||||
completed_items: int,
|
||||
total_items: int,
|
||||
*,
|
||||
same_root: bool,
|
||||
) -> int:
|
||||
self._repository.update_progress(
|
||||
task_id=task_id,
|
||||
@@ -638,7 +647,18 @@ class TaskRunner:
|
||||
total_items=total_items,
|
||||
current_item=file_entry["label"],
|
||||
)
|
||||
self._filesystem.move_file(source=file_entry["source"], destination=file_entry["destination"])
|
||||
try:
|
||||
if same_root:
|
||||
self._filesystem.move_file(source=file_entry["source"], destination=file_entry["destination"])
|
||||
else:
|
||||
self._filesystem.copy_file(source=file_entry["source"], destination=file_entry["destination"])
|
||||
self._filesystem.delete_file(Path(file_entry["source"]))
|
||||
except OSError as exc:
|
||||
if same_root and exc.errno == errno.EXDEV:
|
||||
self._filesystem.copy_file(source=file_entry["source"], destination=file_entry["destination"])
|
||||
self._filesystem.delete_file(Path(file_entry["source"]))
|
||||
else:
|
||||
raise
|
||||
completed_items += 1
|
||||
self._repository.update_progress(
|
||||
task_id=task_id,
|
||||
|
||||
Reference in New Issue
Block a user