Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bootstrapper now correctly access files as ReadWrite only when needed #2920

Merged
merged 1 commit into from Nov 29, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/Paket.Bootstrapper/HelperProxies/FileSystemProxy.cs
Expand Up @@ -38,15 +38,15 @@ public void Touch(string filename)
// wrong happens.
private static readonly TimeSpan WaitHighLimit = TimeSpan.FromMinutes(15);

private static Stream WaitForFileOpen(string path, FileMode filemode)
private static Stream WaitForFileOpen(string path, FileMode filemode, FileAccess fileAccess)
{
Stopwatch watch = null;
int wait = 100;
while (watch == null || watch.Elapsed < WaitHighLimit)
{
try
{
return File.Open(path, filemode, FileAccess.ReadWrite, FileShare.None);
return File.Open(path, filemode, fileAccess, FileShare.None);
}
catch (Exception exception)
{
Expand All @@ -69,12 +69,12 @@ private static Stream WaitForFileOpen(string path, FileMode filemode)

public Stream CreateExclusive(string path)
{
return WaitForFileOpen(path, FileMode.Create);
return WaitForFileOpen(path, FileMode.Create, FileAccess.ReadWrite);
}

public void WaitForFileFinished(string path)
{
WaitForFileOpen(path, FileMode.Open).Dispose();
WaitForFileOpen(path, FileMode.Open, FileAccess.Read).Dispose();
}

public void CreateDirectory(string dir) { Directory.CreateDirectory(dir); }
Expand Down Expand Up @@ -102,7 +102,7 @@ public IEnumerable<string> ReadAllLines(string filename)

public Stream OpenRead(string filename)
{
return WaitForFileOpen(filename, FileMode.Open);
return WaitForFileOpen(filename, FileMode.Open, FileAccess.Read);
}
}
}