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
26 changes: 18 additions & 8 deletions src/Files.App/Utils/Storage/Enumerators/Win32StorageEnumerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ public static class Win32StorageEnumerator
private static readonly IStorageCacheService fileListCache = Ioc.Default.GetRequiredService<IStorageCacheService>();

private static readonly string folderTypeTextLocalized = Strings.Folder.GetLocalizedResource();

// Performance optimization: Increased batch size for better throughput
private const int BATCH_SIZE = 200;

public static async Task<List<ListedItem>> ListEntries(
string path,
Expand Down Expand Up @@ -89,7 +92,7 @@ Func<List<ListedItem>, Task> intermediateAction
if (cancellationToken.IsCancellationRequested || count == countLimit)
break;

if (intermediateAction is not null && (count == 32 || sampler.CheckNow()))
if (intermediateAction is not null && (count == BATCH_SIZE || sampler.CheckNow()))
{
await intermediateAction(tempList);

Expand Down Expand Up @@ -170,9 +173,8 @@ CancellationToken cancellationToken

var itemPath = Path.Combine(pathRoot, findData.cFileName);

string itemName = await fileListCache.GetDisplayName(itemPath, cancellationToken);
if (string.IsNullOrEmpty(itemName))
itemName = findData.cFileName;
// Use the file name directly to avoid async operation during enumeration
string itemName = findData.cFileName;

bool isHidden = (((FileAttributes)findData.dwFileAttributes & FileAttributes.Hidden) == FileAttributes.Hidden);
double opacity = 1;
Expand All @@ -192,7 +194,8 @@ CancellationToken cancellationToken
FileImage = null,
IsHiddenItem = isHidden,
Opacity = opacity,
LoadFileIcon = false,
LoadFileIcon = true, // Show icon immediately to prevent flashing
NeedsPlaceholderGlyph = true,
ItemPath = itemPath,
FileSize = null,
FileSizeBytes = 0,
Expand All @@ -210,7 +213,8 @@ CancellationToken cancellationToken
FileImage = null,
IsHiddenItem = isHidden,
Opacity = opacity,
LoadFileIcon = false,
LoadFileIcon = true, // Show icon immediately to prevent flashing
NeedsPlaceholderGlyph = true,
ItemPath = itemPath,
FileSize = null,
FileSizeBytes = 0,
Expand Down Expand Up @@ -258,7 +262,7 @@ CancellationToken cancellationToken
itemType = itemFileExtension.Trim('.') + " " + itemType;
}

bool itemThumbnailImgVis = false;
bool itemThumbnailImgVis = true; // Changed to true to show icons immediately
bool itemEmptyImgVis = true;

if (cancellationToken.IsCancellationRequested)
Expand All @@ -284,6 +288,7 @@ CancellationToken cancellationToken
Opacity = opacity,
FileImage = null,
LoadFileIcon = itemThumbnailImgVis,
NeedsPlaceholderGlyph = true,
ItemNameRaw = itemName,
ItemDateModifiedReal = itemModifiedDate,
ItemDateAccessedReal = itemLastAccessDate,
Expand All @@ -306,6 +311,7 @@ CancellationToken cancellationToken
Opacity = opacity,
FileImage = null,
LoadFileIcon = itemThumbnailImgVis,
NeedsPlaceholderGlyph = true,
ItemNameRaw = itemName,
ItemDateModifiedReal = itemModifiedDate,
ItemDateAccessedReal = itemLastAccessDate,
Expand Down Expand Up @@ -391,14 +397,16 @@ CancellationToken cancellationToken
}
else
{
if (ZipStorageFolder.IsZipPath(itemPath) && await ZipStorageFolder.CheckDefaultZipApp(itemPath))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please note, changing this logic is likely to cause issues.
#6457

// Quick check for zip extension first to avoid async call for non-zip files
if (FileExtensionHelpers.IsZipFile(itemFileExtension) && ZipStorageFolder.IsZipPath(itemPath))
{
return new ZipItem(null)
{
PrimaryItemAttribute = StorageItemTypes.Folder, // Treat zip files as folders
FileExtension = itemFileExtension,
FileImage = null,
LoadFileIcon = itemThumbnailImgVis,
NeedsPlaceholderGlyph = true,
ItemNameRaw = itemName,
IsHiddenItem = isHidden,
Opacity = opacity,
Expand All @@ -419,6 +427,7 @@ CancellationToken cancellationToken
FileExtension = itemFileExtension,
FileImage = null,
LoadFileIcon = itemThumbnailImgVis,
NeedsPlaceholderGlyph = true,
ItemNameRaw = itemName,
IsHiddenItem = isHidden,
Opacity = opacity,
Expand All @@ -439,6 +448,7 @@ CancellationToken cancellationToken
FileExtension = itemFileExtension,
FileImage = null,
LoadFileIcon = itemThumbnailImgVis,
NeedsPlaceholderGlyph = true,
ItemNameRaw = itemName,
IsHiddenItem = isHidden,
Opacity = opacity,
Expand Down
Loading