Open o-l-a-v opened 5 days ago
I'm no C# expert, I've tried my best to make the delete directory function more robust by trying multiple times. Source of inspiration:
I've also tried to read up on the best way to wait a little between attempts. It's my understanding from what I've read that if function is not async, Thread.Sleep()
is fine.
PR Summary
Make delete more robust by trying multiple times before failing, to fix #1662.
PR Context
In #1662 I experienced that PSResourceGet would fail to install modules because antimalware realtime scanners added file handles on files inside
%TEMP%
that were to be deleted.I read here https://stackoverflow.com/a/329502/9874541 that trying multiple times is a common approach for scenarios like these.
I then tried adapting the existing code to try multiple times on the step that sometimes failed.
I tried the code by building both
net472
andnetstandard2.0
, and I could no longer reproduce #1662.PR Checklist
.h
,.cpp
,.cs
,.ps1
and.psm1
files have the correct copyright headerWIP:
or[ WIP ]
to the beginning of the title (theWIP
bot will keep its status check atPending
while the prefix is present) and remove the prefix when the PR is ready.