-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Allow PowerShell to start even if Data, Home, and Cache folders cannot be created #3244
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -618,14 +618,16 @@ private static byte[] GetHeader() | |
|
|
||
| private int _saveCacheToDiskQueued; | ||
|
|
||
| private bool _saveCacheToDisk = true; | ||
|
|
||
| public void QueueSerialization() | ||
| { | ||
| // We expect many modules to rapidly call for serialization. | ||
| // Instead of doing it right away, we'll queue a task that starts writing | ||
| // after it seems like we've stopped adding stuff to write out. This is | ||
| // avoids blocking the pipeline thread waiting for the write to finish. | ||
| // We want to make sure we only queue one task. | ||
| if (Interlocked.Increment(ref _saveCacheToDiskQueued) == 1) | ||
| if (_saveCacheToDisk && Interlocked.Increment(ref _saveCacheToDiskQueued) == 1) | ||
| { | ||
| Task.Run(async delegate | ||
| { | ||
|
|
@@ -694,6 +696,8 @@ private static void Write(string val, byte[] bytes, FileStream stream) | |
| private void Serialize(string filename) | ||
| { | ||
| AnalysisCacheData fromOtherProcess = null; | ||
| Diagnostics.Assert(_saveCacheToDisk != false, "Serialize should never be called without going through QueueSerialization which has a check"); | ||
|
|
||
| try | ||
| { | ||
| if (Utils.NativeFileExists(filename)) | ||
|
|
@@ -710,7 +714,16 @@ private void Serialize(string filename) | |
| var folder = Path.GetDirectoryName(filename); | ||
| if (!Directory.Exists(folder)) | ||
| { | ||
| Directory.CreateDirectory(folder); | ||
| try | ||
| { | ||
| Directory.CreateDirectory(folder); | ||
| } | ||
| catch (UnauthorizedAccessException) | ||
| { | ||
| // service accounts won't be able to create directory | ||
|
||
| _saveCacheToDisk = false; | ||
| return; | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What sort of contract should this api have? If the directory can't be used, should this api return null instead?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Path.Combine() is used often with this api and would have a problem with null. My thinking was that this api returns the expected path which may be used in error message, so even returning an empty string may produce undesired results.