in Core/src/Impl/Commands/LocalFilesScanner.cs [47:68]
public async Task<Statistics> ExecuteAsync()
{
myLogger.Info($"[{DateTime.Now:s}] Scanning source files...");
var statistics = new Statistics();
ITracer tracer = new Tracer(new LoggerWithStatistics(myLogger, statistics));
List<List<(string dir, string file)>> items = mySources.ParallelFor(myDegreeOfParallelism, source =>
{
var fullPath = Path.GetFullPath(source);
if (File.Exists(fullPath))
return [(string.IsNullOrEmpty(myBaseDir) ? Path.GetDirectoryName(fullPath) ?? "" : myBaseDir, fullPath)];
if (Directory.Exists(fullPath))
return Directory.GetFiles(fullPath, "*", SearchOption.AllDirectories).Select(x => (string.IsNullOrEmpty(myBaseDir) ? fullPath : myBaseDir, x)).ToList();
tracer.Error($"The source path {fullPath} doesn't exist");
return [];
});
await items.SelectMany(x => x).ParallelForAsync(myDegreeOfParallelism, item => new ValueTask(ScanFileAsync(item.dir, item.file, tracer)));
return statistics;
}