Skip to content
Merged
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
15 changes: 10 additions & 5 deletions src/Files/ViewModels/Properties/FolderProperties.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,11 @@ public async override void GetSpecialProperties()
}
}

string folderPath = (Item as ShortcutItem)?.TargetPath ?? Item.ItemPath;
BaseStorageFolder storageFolder;
try
{
storageFolder = await AppInstance.FilesystemViewModel.GetFolderFromPathAsync((Item as ShortcutItem)?.TargetPath ?? Item.ItemPath);
storageFolder = await AppInstance.FilesystemViewModel.GetFolderFromPathAsync(folderPath);
}
catch (Exception ex)
{
Expand All @@ -120,7 +121,7 @@ public async override void GetSpecialProperties()
{
GetOtherProperties(storageFolder.Properties);
}
GetFolderSize(storageFolder, TokenSource.Token);
GetFolderSize(storageFolder.Path, TokenSource.Token);
}
else if (Item.ItemPath.Equals(CommonPaths.RecycleBinPath, StringComparison.OrdinalIgnoreCase))
{
Expand Down Expand Up @@ -162,11 +163,15 @@ public async override void GetSpecialProperties()
}
}
}
else
{
GetFolderSize(folderPath, TokenSource.Token);
}
}

private async void GetFolderSize(BaseStorageFolder storageFolder, CancellationToken token)
private async void GetFolderSize(string folderPath, CancellationToken token)
{
if (string.IsNullOrEmpty(storageFolder.Path))
if (string.IsNullOrEmpty(folderPath))
{
// In MTP devices calculating folder size would be too slow
// Also should use StorageFolder methods instead of FindFirstFileExFromApp
Expand All @@ -178,7 +183,7 @@ private async void GetFolderSize(BaseStorageFolder storageFolder, CancellationTo

var fileSizeTask = Task.Run(async () =>
{
var size = await CalculateFolderSizeAsync(storageFolder.Path, token);
var size = await CalculateFolderSizeAsync(folderPath, token);
return size;
});
try
Expand Down