Skip to content
Open
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -19,27 +19,28 @@ public static async Task<List<ListedItem>> ListEntries(
Func<List<ListedItem>, Task> intermediateAction,
Dictionary<string, BitmapImage> defaultIconPairs = null)
{
var sampler = new IntervalSampler(500);
var sampler = new IntervalSampler(5000);
var tempList = new List<ListedItem>();
uint count = 0;
var firstRound = true;
var disableIntermediateUpdates = false;

IUserSettingsService userSettingsService = Ioc.Default.GetRequiredService<IUserSettingsService>();

while (true)
{
IReadOnlyList<IStorageItem> items;

uint maxItemsToRetrieve = 300;
uint maxItemsToRetrieve = 5000;

if (intermediateAction is null)
{
// without intermediate action increase batches significantly
maxItemsToRetrieve = 1000;
maxItemsToRetrieve = 10000;
}
else if (firstRound)
{
maxItemsToRetrieve = 32;
maxItemsToRetrieve = 1000;
firstRound = false;
}

Expand Down Expand Up @@ -116,7 +117,10 @@ ex is FileNotFoundException ||
if (countLimit > -1 && count >= countLimit)
break;

if (intermediateAction is not null && (items.Count == maxItemsToRetrieve || sampler.CheckNow()))
if (count > 50000 && !disableIntermediateUpdates)
disableIntermediateUpdates = true;

if (intermediateAction is not null && !disableIntermediateUpdates && (items.Count == maxItemsToRetrieve || sampler.CheckNow()))
{
await intermediateAction(tempList);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,10 @@ public static async Task<List<ListedItem>> ListEntries(
Func<List<ListedItem>, Task> intermediateAction
)
{
var sampler = new IntervalSampler(500);
var sampler = new IntervalSampler(5000);
var tempList = new List<ListedItem>();
var count = 0;
var disableIntermediateUpdates = false;

IUserSettingsService userSettingsService = Ioc.Default.GetRequiredService<IUserSettingsService>();
bool CalculateFolderSizes = userSettingsService.FoldersSettingsService.CalculateFolderSizes;
Expand Down Expand Up @@ -89,7 +90,10 @@ Func<List<ListedItem>, Task> intermediateAction
if (cancellationToken.IsCancellationRequested || count == countLimit)
break;

if (intermediateAction is not null && (count == 32 || sampler.CheckNow()))
if (count > 50000 && !disableIntermediateUpdates)
disableIntermediateUpdates = true;

if (intermediateAction is not null && !disableIntermediateUpdates && (count % 10000 == 0 || sampler.CheckNow()))
{
await intermediateAction(tempList);

Expand Down
Loading