bau
bau copied to clipboard
Filesystem helper methods
E.g. CreateDirectory()
and DeleteDirectory()
methods which actually block until the operation has happened.
Removes the need for things like https://github.com/bau-build/bau/blob/7b0e3a080f324d6a40b710f161fca76c7ea02d18/baufile.csx#L133-L148
:+1:
Also possible to check for Directory.Exists
in a loop and have a configurable maxWaitMs
parameter.
Is the problem easily reproducible, such that a fix could be tested? I tried commenting out that line and deleting the artifacts directory, but I was not able to reproduce the problem. I imagine it only happens on machines with slower file systems.
I am curious because I have seen a couple of places that suggest that calling DirectoryInfo.Refresh acts like a synchronous wait until the directory is actually created, and I want to try it out.
I had tried to reproduce this issue myself recently and actually could not. I am 99% positive I have seen behavior where after deleting a directory it was not fully done being deleted when it returned control to me, but that was a long time ago and may no longer be a problem. I think on Linux stuff may also be more problematic as the delete may not actually happen until the files in the folder are done being used.
IIRC it was one of the CI builds where this problem manifested, probably Travis.
Easily reproducible? Probably not :wink:
For reference, this has been implemented for the acceptance testing so one option is to just lift this code out into Bau itself https://github.com/bau-build/bau/blob/13e19b27647881e931dd76884a9500baa7b0d6ed/src/test/Bau.Test.Acceptance/Support/FileSystem.cs