powershell

Dismount components cleanly when a scan ISN'T your process: flocks, retries, and backoff

Good scripts treat sharing violations as expected load. The retry-with-backoff pattern, and when the honest answer is 'skip it' instead of retry harder.

ProofTune Project··4 min read
PowerShell illustration PowerShell

Retry with bounded backoff

terminal / powershell
$max = 3; $delay = 300
for ($attempt = 1; $attempt -le $max; $attempt++) {
  try { [IO.File]::WriteAllText($path, $content); break }
  catch [IO.IOException] {
    if ($attempt -eq $max) { Write-Verbose "Skipped (in use): $path"; break }
    Start-Sleep -Milliseconds $delay; $delay *= 2
  }
}

Judgement, not just mechanics

  • Exponential ceiling: 300 ms → 600 ms → 1.2 s caps total wait at ~2 seconds; a busy file next sign-in is free to win next time.
  • Distinguish violation from authorization: IOException from sharing-lock is transient; from ACL is permanent — retrying the latter is just theatre that a log-reader can't un-watch.
  • Delete-skip balance: for cleanup-scoped tasks, skipping is correct on first lock, with a counter reported. For authoritative writes (journals), retries before the entry are warranted — journal-integrity outweighs amenity.

Tools get trusted on weird days: the test is whether their logs let you say precisely which bytes were skipped, at which attempt, and why — rather than “something failed somewhere.”

ProofTune ProjectEngineering notes — every claim here names the bytes a real tool touches. Verify first, install second.
ProofTune logo

See these exact settings inside the real tool

The browser replica runs the same strings and states as the installed app — click around before you ever install anything.