feat: contextmenu copy folders toegevoegd

This commit is contained in:
kodi
2026-03-14 10:34:31 +01:00
parent 8908b1dce9
commit 4e1288fe47
16 changed files with 440 additions and 60 deletions
+93
View File
@@ -22,6 +22,22 @@ class TaskRunner:
)
thread.start()
def enqueue_copy_directory(self, task_id: str, source: str, destination: str) -> None:
thread = threading.Thread(
target=self._run_copy_directory,
args=(task_id, source, destination),
daemon=True,
)
thread.start()
def enqueue_copy_batch(self, task_id: str, items: list[dict[str, str]]) -> None:
thread = threading.Thread(
target=self._run_copy_batch,
args=(task_id, items),
daemon=True,
)
thread.start()
def enqueue_move_file(
self,
task_id: str,
@@ -91,6 +107,83 @@ class TaskRunner:
)
self._update_history_failed(task_id, str(exc))
def _run_copy_directory(self, task_id: str, source: str, destination: str) -> None:
self._repository.mark_running(
task_id=task_id,
done_items=0,
total_items=1,
current_item=source,
)
try:
self._filesystem.copy_directory(source=source, destination=destination)
self._repository.mark_completed(
task_id=task_id,
done_items=1,
total_items=1,
)
self._update_history_completed(task_id)
except OSError as exc:
self._repository.mark_failed(
task_id=task_id,
error_code="io_error",
error_message=str(exc),
failed_item=source,
done_bytes=None,
total_bytes=None,
done_items=0,
total_items=1,
)
self._update_history_failed(task_id, str(exc))
def _run_copy_batch(self, task_id: str, items: list[dict[str, str]]) -> None:
total_items = len(items)
current_item = items[0]["source"] if items else None
self._repository.mark_running(
task_id=task_id,
done_items=0,
total_items=total_items,
current_item=current_item,
)
completed_items = 0
for index, item in enumerate(items):
source = item["source"]
destination = item["destination"]
try:
if item["kind"] == "directory":
self._filesystem.copy_directory(source=source, destination=destination)
else:
self._filesystem.copy_file(source=source, destination=destination)
completed_items = index + 1
next_item = items[index + 1]["source"] if index + 1 < total_items else source
self._repository.update_progress(
task_id=task_id,
done_items=completed_items,
total_items=total_items,
current_item=next_item,
)
except OSError as exc:
self._repository.mark_failed(
task_id=task_id,
error_code="io_error",
error_message=str(exc),
failed_item=source,
done_bytes=None,
total_bytes=None,
done_items=completed_items,
total_items=total_items,
)
self._update_history_failed(task_id, str(exc))
return
self._repository.mark_completed(
task_id=task_id,
done_items=total_items,
total_items=total_items,
)
self._update_history_completed(task_id)
def _run_move_file(
self,
task_id: str,