Public Access
This commit is contained in:
@@ -189,7 +189,7 @@ internal static class AgentFileToolContent
|
||||
var limit = Math.Clamp(maxMatches, 1, 1000);
|
||||
foreach (var source in sources)
|
||||
{
|
||||
var lines = File.ReadAllLines(source.Path);
|
||||
var lines = ReadAllLinesShared(source.Path);
|
||||
for (var index = 0; index < lines.Length; index++)
|
||||
{
|
||||
if (regex.IsMatch(lines[index]))
|
||||
@@ -211,6 +211,30 @@ internal static class AgentFileToolContent
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
public static async Task<string> ReadAllTextSharedAsync(string path)
|
||||
{
|
||||
await using var stream = new FileStream(
|
||||
path,
|
||||
FileMode.Open,
|
||||
FileAccess.Read,
|
||||
FileShare.ReadWrite | FileShare.Delete,
|
||||
bufferSize: 4096,
|
||||
useAsync: true);
|
||||
using var reader = new StreamReader(stream);
|
||||
return await reader.ReadToEndAsync();
|
||||
}
|
||||
|
||||
private static string[] ReadAllLinesShared(string path)
|
||||
{
|
||||
using var stream = new FileStream(
|
||||
path,
|
||||
FileMode.Open,
|
||||
FileAccess.Read,
|
||||
FileShare.ReadWrite | FileShare.Delete);
|
||||
using var reader = new StreamReader(stream);
|
||||
return SplitLines(reader.ReadToEnd()).ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
internal sealed record AgentFileSearchSource(string Path, string DisplayPath);
|
||||
|
||||
@@ -166,7 +166,7 @@ public sealed class WorkflowRulesEditorTools
|
||||
return $"Log file was not found: {logFile ?? MeetingAssistantLogFiles.CurrentLogFileName}";
|
||||
}
|
||||
|
||||
var content = await File.ReadAllTextAsync(path);
|
||||
var content = await AgentFileToolContent.ReadAllTextSharedAsync(path);
|
||||
if (from.HasValue || to.HasValue)
|
||||
{
|
||||
return AgentFileToolContent.ReadLines(content, from, to);
|
||||
|
||||
Reference in New Issue
Block a user