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

Remove longpath prefixes before using AllowFileAccessAfterProjectFinishFilePatterns #44

Merged
merged 1 commit into from
Jan 25, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions src/Common/FileAccess/FileAccessRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ public void Dispose()

public void AddFileAccess(FileAccessData fileAccessData)
{
string path = PathHelper.RemoveLongPathPrefixes(fileAccessData.Path);
lock (_stateLock)
{
if (_isFinished)
Expand All @@ -111,28 +112,27 @@ public void AddFileAccess(FileAccessData fileAccessData)
processMatch = IsAllowFileAccessAfterProjectFinishProcessPatterns(processName);
}

Glob? fileMatch = IsAllowFileAccessAfterProjectFinishFilePatterns(fileAccessData.Path);
Glob? fileMatch = IsAllowFileAccessAfterProjectFinishFilePatterns(path);

processName ??= $"ProcessId: {fileAccessData.ProcessId}";

if (processMatch != null)
{
_logger.LogWarning(
$"File access reported from process after the project finished, but process matched {nameof(_pluginSettings.AllowFileAccessAfterProjectFinishProcessPatterns)} `{processMatch}`. " +
$"This may lead to incorrect caching. Node Id: {_nodeContext.Id}, Process Id: {fileAccessData.ProcessId} ProcessPath: `{processName}` File Path: `{fileAccessData.Path}`");
$"This may lead to incorrect caching. Node Id: {_nodeContext.Id}, Process Id: {fileAccessData.ProcessId} ProcessPath: `{processName}` File Path: `{path}`");
}
else if (fileMatch != null)
{
_logger.LogWarning(
$"File access reported from process after the project finished, but file path matched {nameof(_pluginSettings.AllowFileAccessAfterProjectFinishFilePatterns)} `{fileMatch}`. " +
$"This may lead to incorrect caching. Node Id: {_nodeContext.Id}, Process Id: {fileAccessData.ProcessId} ProcessPath: `{processName}` File Path: `{fileAccessData.Path}`");
$"This may lead to incorrect caching. Node Id: {_nodeContext.Id}, Process Id: {fileAccessData.ProcessId} ProcessPath: `{processName}` File Path: `{path}`");
}
else
{
// HERE
throw new InvalidOperationException(
$"File access reported from process `{processName}` after the project finished. " +
$"This may lead to incorrect caching. Node Id: {_nodeContext.Id}, Path: {fileAccessData.Path}");
$"This may lead to incorrect caching. Node Id: {_nodeContext.Id}, Path: {path}");
}
}

Expand All @@ -151,7 +151,6 @@ public void AddFileAccess(FileAccessData fileAccessData)

uint processId = fileAccessData.ProcessId;
RequestedAccess requestedAccess = fileAccessData.RequestedAccess;
string path = PathHelper.RemoveLongPathPrefixes(fileAccessData.Path);
uint error = fileAccessData.Error;

// Used to identify file accesses reconstructed from breakaway processes, such as csc.exe when using shared compilation.
Expand All @@ -166,7 +165,7 @@ public void AddFileAccess(FileAccessData fileAccessData)
if (operation == ReportedFileOperation.Process)
{
_logFileStream.WriteLine($"New process: PId {processId}, process name {path}, arguments {fileAccessData.ProcessArgs}");
_processTable.TryAdd(processId, fileAccessData.Path);
_processTable.TryAdd(processId, path);
}

_logFileStream.WriteLine(isAnAugmentedFileAccess
Expand Down