Skip to content

Commit 6a471e7

Browse files
committed
Always save at most 32 items to cache
1 parent c5a2a7a commit 6a471e7

File tree

1 file changed

+15
-22
lines changed

1 file changed

+15
-22
lines changed

Files/ViewModels/ItemViewModel.cs

+15-22
Original file line numberDiff line numberDiff line change
@@ -762,7 +762,6 @@ await CoreApplication.MainView.DispatcherQueue.EnqueueAsync(() =>
762762
{
763763
await OrderFilesAndFoldersAsync();
764764
await ApplySingleFileChangeAsync(item);
765-
//await SaveCurrentListToCacheAsync(WorkingDirectory);
766765
}
767766
}
768767
var syncStatus = await CheckCloudDriveSyncStatusAsync(matchingStorageItem);
@@ -885,7 +884,10 @@ private async void RapidAddItemsToCollectionAsync(string path, string previousDi
885884
{
886885
for (var i = 0; i < cacheEntry.FileList.Count; i++)
887886
{
888-
filesAndFolders.Add(cacheEntry.FileList[i]);
887+
if (!cacheEntry.FileList[i].IsHiddenItem || AppSettings.AreHiddenItemsVisible)
888+
{
889+
filesAndFolders.Add(cacheEntry.FileList[i]);
890+
}
889891
if (addFilesCTS.IsCancellationRequested)
890892
{
891893
break;
@@ -901,6 +903,10 @@ private async void RapidAddItemsToCollectionAsync(string path, string previousDi
901903
}
902904
return null;
903905
});
906+
if (cacheResult != null)
907+
{
908+
IsLoadingItems = false;
909+
}
904910
}
905911

906912
if (path.StartsWith(AppSettings.RecycleBinPath) ||
@@ -1242,11 +1248,7 @@ await DialogDisplayHelper.ShowDialogAsync(
12421248
if (cacheOnly)
12431249
{
12441250
fileList = await Win32StorageEnumerator.ListEntries(path, returnformat, hFile, findData, Connection, cancellationToken, skipItems, 32, null);
1245-
await fileListCache.SaveFileListToCache(path, new CacheEntry
1246-
{
1247-
CurrentFolder = currentFolder,
1248-
FileList = fileList
1249-
});
1251+
await SaveFileListToCacheAsync(path, fileList);
12501252
}
12511253
else
12521254
{
@@ -1276,12 +1278,7 @@ await DialogDisplayHelper.ShowDialogAsync(
12761278
{
12771279
if (!addFilesCTS.IsCancellationRequested)
12781280
{
1279-
await fileListCache.SaveFileListToCache(path, new CacheEntry
1280-
{
1281-
CurrentFolder = CurrentFolder,
1282-
// since filesAndFolders could be mutated, memory cache needs a copy of current list
1283-
FileList = filesAndFolders.ToList()
1284-
});
1281+
await SaveFileListToCacheAsync(path, filesAndFolders);
12851282
}
12861283
else
12871284
{
@@ -1313,11 +1310,7 @@ private async Task EnumFromStorageFolderAsync(string path, ListedItem currentFol
13131310
null,
13141311
32,
13151312
null);
1316-
await fileListCache.SaveFileListToCache(path, new CacheEntry
1317-
{
1318-
CurrentFolder = currentFolder,
1319-
FileList = finalList
1320-
});
1313+
await SaveFileListToCacheAsync(path, finalList);
13211314
}
13221315
else
13231316
{
@@ -1354,7 +1347,7 @@ private async Task EnumFromStorageFolderAsync(string path, ListedItem currentFol
13541347
{
13551348
if (!addFilesCTS.IsCancellationRequested)
13561349
{
1357-
await SaveCurrentListToCacheAsync(path);
1350+
await SaveFileListToCacheAsync(path, filesAndFolders);
13581351
}
13591352
else
13601353
{
@@ -1547,7 +1540,7 @@ private async void ProcessOperationQueue(CancellationToken cancellationToken)
15471540

15481541
await OrderFilesAndFoldersAsync();
15491542
await ApplyFilesAndFoldersChangesAsync();
1550-
await SaveCurrentListToCacheAsync(WorkingDirectory);
1543+
await SaveFileListToCacheAsync(WorkingDirectory, filesAndFolders);
15511544
}
15521545
}
15531546
catch
@@ -1747,13 +1740,13 @@ private async Task UpdateFileOrFolderAsync(string path)
17471740
}
17481741
}
17491742

1750-
private Task SaveCurrentListToCacheAsync(string path)
1743+
private Task SaveFileListToCacheAsync(string path, IEnumerable<ListedItem> fileList)
17511744
{
17521745
return fileListCache.SaveFileListToCache(path, new CacheEntry
17531746
{
17541747
CurrentFolder = CurrentFolder,
17551748
// since filesAndFolders could be mutated, memory cache needs a copy of current list
1756-
FileList = filesAndFolders.Take(32).ToList()
1749+
FileList = fileList.Take(32).ToList()
17571750
});
17581751
}
17591752

0 commit comments

Comments
 (0)