Skip to content

Commit e75283f

Browse files
Merge pull request #51 from TheGuitarleader/patch/improvements
Optimized file system scanning.
2 parents 03c45d8 + 35b5e4c commit e75283f

3 files changed

Lines changed: 18 additions & 34 deletions

File tree

Build-Release.bat

Lines changed: 0 additions & 13 deletions
This file was deleted.
File renamed without changes.

Parallel.Core/IO/Scanning/FileScanner.cs

Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -73,14 +73,14 @@ public async Task<SystemFile[]> GetFileChangesAsync(string path, string[] ignore
7373
SystemFile localFile = new SystemFile(remoteFile.LocalPath);
7474
if (IsIgnored(localFile.LocalPath, ignoreFolders))
7575
{
76-
Log.Debug($"Ignored -> {localFile.LocalPath}");
76+
//Log.Debug($"Ignored -> {localFile.LocalPath}");
7777
localFile.RemotePath = remoteFile.RemotePath;
7878
localFile.Deleted = true;
7979
changedFiles.Add(localFile);
8080
}
8181
else if (HasChanged(localFile, remoteFile) || force)
8282
{
83-
Log.Debug($"Changed -> {localFile.LocalPath}");
83+
//Log.Debug($"Changed -> {localFile.LocalPath}");
8484
localFile.RemotePath = remoteFile.RemotePath;
8585
changedFiles.Add(localFile);
8686
}
@@ -89,31 +89,18 @@ public async Task<SystemFile[]> GetFileChangesAsync(string path, string[] ignore
8989
}
9090
else
9191
{
92-
Log.Debug($"Deleted -> {remoteFile.LocalPath}");
92+
//Log.Debug($"Deleted -> {remoteFile.LocalPath}");
9393
remoteFile.Deleted = true;
9494
changedFiles.Add(remoteFile);
9595
}
9696
});
9797

98-
HashSet<string> remainingFiles = localFiles.Except(new HashSet<string>(scannedFiles)).ToHashSet();
99-
Log.Debug($"{remainingFiles.Count} files are untracked! Adding...");
100-
101-
remainingFiles.AsParallel().WithDegreeOfParallelism(Environment.ProcessorCount).Where(f => !IsIgnored(f, ignoreFolders)).ForAll(file =>
98+
// Adds the remaining files as created
99+
foreach (string file in localFiles.Except(new HashSet<string>(scannedFiles)))
102100
{
103-
Log.Debug($"Created -> {file}");
101+
//Log.Debug($"Created -> {file}");
104102
changedFiles.Add(new SystemFile(file));
105-
});
106-
107-
// System.Threading.Tasks.Parallel.ForEach(remainingFiles, ParallelConfig.Options, (file, ct) =>
108-
// {
109-
// if (!IsIgnored(file, ignoreFolders))
110-
// {
111-
// Log.Debug($"Created -> {file}");
112-
// changedFiles.Add(new SystemFile(file) { RemotePath = PathBuilder.Remote(file, _config) });
113-
// }
114-
//
115-
// Log.Debug($"Done");
116-
// });
103+
}
117104

118105
Log.Information($"Found {changedFiles.Count:N0} changes in '{path}'");
119106
return changedFiles.ToArray();
@@ -257,7 +244,17 @@ public static IEnumerable<string> GetFiles(string root, string[] exempt, string
257244
continue;
258245
}
259246

260-
foreach (string file in files) yield return file;
247+
foreach (string file in files)
248+
{
249+
if (IsIgnored(file, exempt))
250+
{
251+
Log.Debug($"Ignored -> {file}");
252+
continue;
253+
}
254+
255+
yield return file;
256+
}
257+
261258
if (!recursive) continue;
262259
IEnumerable<string> subDirs;
263260
try

0 commit comments

Comments
 (0)