Skip to content

Commit fe6018e

Browse files
committed
bulk update
1 parent 9f48540 commit fe6018e

File tree

1 file changed

+5
-19
lines changed

1 file changed

+5
-19
lines changed

Diff for: Files/ViewModels/ItemViewModel.cs

+5-19
Original file line numberDiff line numberDiff line change
@@ -1818,7 +1818,6 @@ private async void ProcessOperationQueue(CancellationToken cancellationToken, bo
18181818
const uint FILE_ACTION_RENAMED_NEW_NAME = 0x00000005;
18191819

18201820
var sampler = new IntervalSampler(200);
1821-
var updateList = new HashSet<string>();
18221821
bool anyEdits = false;
18231822

18241823
try
@@ -1828,8 +1827,8 @@ private async void ProcessOperationQueue(CancellationToken cancellationToken, bo
18281827
if (operationEvent.Wait(200, cancellationToken))
18291828
{
18301829
operationEvent.Reset();
1830+
var updateList = new HashSet<string>();
18311831

1832-
processQueue:
18331832
while (operationQueue.TryDequeue(out var operation))
18341833
{
18351834
if (cancellationToken.IsCancellationRequested) break;
@@ -1867,16 +1866,7 @@ private async void ProcessOperationQueue(CancellationToken cancellationToken, bo
18671866
}
18681867
}
18691868

1870-
foreach (var entry in updateList.ToList())
1871-
{
1872-
await UpdateFileOrFolderAsync(entry, hasSyncStatus);
1873-
updateList.Remove(entry);
1874-
1875-
if (sampler.CheckNow() && operationQueue.Any(i => i.Action != FILE_ACTION_MODIFIED))
1876-
{
1877-
goto processQueue;
1878-
}
1879-
}
1869+
await UpdateFilesOrFoldersAsync(updateList, hasSyncStatus);
18801870
}
18811871

18821872
if (anyEdits)
@@ -2069,7 +2059,7 @@ await CoreApplication.MainView.DispatcherQueue.EnqueueAsync(async () =>
20692059
}
20702060
}
20712061

2072-
private async Task UpdateFileOrFolderAsync(string path, bool hasSyncStatus = false)
2062+
private async Task UpdateFilesOrFoldersAsync(IEnumerable<string> paths, bool hasSyncStatus = false)
20732063
{
20742064
try
20752065
{
@@ -2082,12 +2072,8 @@ private async Task UpdateFileOrFolderAsync(string path, bool hasSyncStatus = fal
20822072

20832073
try
20842074
{
2085-
var matchingItem = filesAndFolders.FirstOrDefault(x => x.ItemPath.Equals(path, StringComparison.OrdinalIgnoreCase));
2086-
2087-
if (matchingItem != null)
2088-
{
2089-
await UpdateFileOrFolderAsync(matchingItem, hasSyncStatus);
2090-
}
2075+
var matchingItems = filesAndFolders.Where(x => paths.Any(p => p.Equals(x.ItemPath, StringComparison.OrdinalIgnoreCase)));
2076+
await Task.WhenAll(matchingItems.Select(x => UpdateFileOrFolderAsync(x, hasSyncStatus)));
20912077
}
20922078
finally
20932079
{

0 commit comments

Comments
 (0)