bau icon indicating copy to clipboard operation
bau copied to clipboard

Filesystem helper methods

Open adamralph opened this issue 9 years ago • 5 comments

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

adamralph avatar Dec 01 '14 10:12 adamralph

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

aarondandy avatar Dec 01 '14 14:12 aarondandy

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.

eatdrinksleepcode avatar Jun 24 '15 02:06 eatdrinksleepcode

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.

aarondandy avatar Jun 24 '15 20:06 aarondandy

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

Easily reproducible? Probably not :wink:

adamralph avatar Jun 28 '15 11:06 adamralph

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

adamralph avatar Jun 28 '15 11:06 adamralph