Skip to content

Commit

Permalink
Fix: Fixed issue with browsing WSL drives (#11793)
Browse files Browse the repository at this point in the history
  • Loading branch information
marcofranzen99 authored Mar 22, 2023
1 parent 6ca26dc commit b428e71
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
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

0 comments on commit b428e71

Please sign in to comment.