feat: voortgang copy/duplicate/move in headerbar

This commit is contained in:
kodi
2026-03-15 11:40:21 +01:00
parent 9d5fb5a0c9
commit 73b09d2802
24 changed files with 1104 additions and 2 deletions
@@ -107,6 +107,64 @@ class TaskRepositoryTest(unittest.TestCase):
self.assertEqual(task["status"], "cancelled")
self.assertIsNotNone(task["finished_at"])
def test_reconcile_incomplete_tasks_marks_non_terminal_failed(self) -> None:
self.repo.insert_task_for_testing(
{
"id": "task-running",
"operation": "copy",
"status": "running",
"source": "storage1/a",
"destination": "storage2/a",
"created_at": "2026-03-10T09:00:00Z",
"started_at": "2026-03-10T09:00:01Z",
"current_item": "storage1/a",
}
)
self.repo.insert_task_for_testing(
{
"id": "task-completed",
"operation": "copy",
"status": "completed",
"source": "storage1/b",
"destination": "storage2/b",
"created_at": "2026-03-10T09:05:00Z",
"finished_at": "2026-03-10T09:06:00Z",
}
)
changed = self.repo.reconcile_incomplete_tasks()
running = self.repo.get_task("task-running")
completed = self.repo.get_task("task-completed")
self.assertEqual(changed, ["task-running"])
self.assertEqual(running["status"], "failed")
self.assertEqual(running["error_code"], "task_interrupted")
self.assertEqual(running["error_message"], "Task was interrupted before completion")
self.assertIsNone(running["current_item"])
self.assertIsNotNone(running["finished_at"])
self.assertEqual(completed["status"], "completed")
def test_reconcile_incomplete_tasks_removes_stale_artifact(self) -> None:
created = self.repo.create_task(
operation="download",
source="storage1/docs",
destination="docs.zip",
status="preparing",
)
self.repo.upsert_artifact(
task_id=created["id"],
file_path="/tmp/docs.zip.partial",
file_name="docs.zip",
expires_at="2026-03-10T10:30:00Z",
)
changed = self.repo.reconcile_incomplete_tasks()
task = self.repo.get_task(created["id"])
self.assertEqual(changed, [created["id"]])
self.assertEqual(task["status"], "failed")
self.assertIsNone(self.repo.get_artifact(created["id"]))
def test_migrates_legacy_tasks_schema_missing_source_destination(self) -> None:
legacy_db_path = Path(self.temp_dir.name) / "legacy.db"
conn = sqlite3.connect(legacy_db_path)