Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Fixed issue with browsing WSL drives #11793

Merged
merged 4 commits into from
Mar 22, 2023
Merged
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
9 changes: 9 additions & 0 deletions src/Files.App/Filesystem/WSLDistroManager.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Files.App.DataModels.NavigationControlItems;
using Files.App.Helpers;
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
Expand Down Expand Up @@ -59,6 +60,14 @@ public async Task UpdateDrivesAsync()
}
}

public bool TryGetDistro(string path, out WslDistroItem? distro)
{
var normalizedPath = PathNormalization.NormalizePath(path);
distro = Distros.FirstOrDefault(x => normalizedPath.StartsWith(PathNormalization.NormalizePath(x.Path), StringComparison.OrdinalIgnoreCase));

return distro is not null;
}

private static Uri GetLogoUri(string displayName)
{
if (Contains(displayName, "ubuntu"))
Expand Down
5 changes: 4 additions & 1 deletion src/Files.App/ViewModels/ItemViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1474,7 +1474,10 @@ public async Task<int> EnumerateItemsFromStandardFolderAsync(string path, Cancel
{
// Flag to use FindFirstFileExFromApp or StorageFolder enumeration - Use storage folder for Box Drive (#4629)
var isBoxFolder = App.CloudDrivesManager.Drives.FirstOrDefault(x => x.Text == "Box")?.Path?.TrimEnd('\\') is string boxFolder && path.StartsWith(boxFolder);
bool isNetwork = path.StartsWith(@"\\", StringComparison.Ordinal) && !path.StartsWith(@"\\?\", StringComparison.Ordinal);
bool isWslDistro = App.WSLDistroManager.TryGetDistro(path, out _);
bool isNetwork = path.StartsWith(@"\\", StringComparison.Ordinal) &&
!path.StartsWith(@"\\?\", StringComparison.Ordinal) &&
!isWslDistro;
bool enumFromStorageFolder = isBoxFolder;

BaseStorageFolder? rootFolder = null;
Expand Down