mirror of
https://github.com/GoodOlClint/PSProxmoxVE.git
synced 2026-09-03 18:55:33 +00:00
17832f15d9
WaitPveTaskCmdlet hand-rolled its own poll loop (while(true) / Thread.Sleep / JObject.Parse), the exact pattern ADR 0001 forbids. It now delegates to TaskService.WaitForTask, passing a progress callback that drives WriteProgress — the seam WaitForTask was built for and that nothing called until now. Preserves the cmdlet's own documented contract (an omitted -Timeout waits indefinitely) by passing a 100-year sentinel instead of null, since TaskService.WaitForTask treats a null timeout as its own 10-minute default, not infinite. Reuses one PveHttpClient for the whole wait instead of letting TaskService open a fresh one per poll. Also strips the redundant trailing 'null, null, null' default arguments from 12 other WaitForTask call sites so they use the short form, per the issue. Left CopyPveContainerCmdlet.cs, ImportPveOvaCmdlet.cs and NewPveVmCmdlet.cs alone — issue #135 is touching those concurrently. Adds three xUnit tests to TaskServiceTests.cs proving the behavior the inline loop got wrong: no sleep before the first status check, the 1-second MinPollInterval clamp, and the progress callback firing on every poll. Mutation-tested by breaking each behavior in turn and confirming the corresponding test fails. Closes #140 Co-authored-by: goodolclint-claude[bot] <323206664+goodolclint-claude[bot]@users.noreply.github.com>