adamralph / bau

The C# task runner
MIT License
152 stars 17 forks source link

Filesystem helper methods #187

Open adamralph opened 9 years ago

adamralph commented 9 years ago

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

aarondandy commented 9 years ago

:+1: Also possible to check for Directory.Exists in a loop and have a configurable maxWaitMs parameter.

eatdrinksleepcode commented 9 years ago

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.

aarondandy commented 9 years ago

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.

adamralph commented 9 years ago

IIRC it was one of the CI builds where this problem manifested, probably Travis.

Easily reproducible? Probably not :wink:

adamralph commented 9 years ago

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