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 for archive files #13778

Merged
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
15 changes: 8 additions & 7 deletions src/Files.App/ViewModels/Properties/Items/CombinedProperties.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,9 @@ public override async Task GetSpecialPropertiesAsync()
long filesSize = List.Where(x => x.PrimaryItemAttribute == StorageItemTypes.File).Sum(x => x.FileSizeBytes);
long foldersSize = 0;
long totalSizeOnDisk = 0;
long filesSizeOnDisk = List.Where(x => x.PrimaryItemAttribute == StorageItemTypes.File)
.Sum(x => NativeFileOperationsHelper.GetFileSizeOnDisk(x.ItemPath) ?? 0);
long filesSizeOnDisk = List.Where(x => x.PrimaryItemAttribute == StorageItemTypes.File &&
x.SyncStatusUI.SyncStatus is not CloudDriveSyncStatus.FileOnline and not CloudDriveSyncStatus.FolderOnline)
.Sum(x => NativeFileOperationsHelper.GetFileSizeOnDisk(x.ItemPath) ?? 0);
long foldersSizeOnDisk = 0;

ViewModel.ItemSizeProgressVisibility = true;
Expand All @@ -84,12 +85,12 @@ public override async Task GetSpecialPropertiesAsync()
{
if (item.PrimaryItemAttribute == StorageItemTypes.Folder)
{
var fileSizeTask = Task.Run(async () =>
{
var size = await CalculateFolderSizeAsync(item.ItemPath, TokenSource.Token);
if (item.SyncStatusUI.SyncStatus is CloudDriveSyncStatus.FileOnline or
CloudDriveSyncStatus.FolderOnline or
CloudDriveSyncStatus.FolderOfflinePartial)
continue;

return size;
});
var fileSizeTask = Task.Run(() => CalculateFolderSizeAsync(item.ItemPath, TokenSource.Token));

try
{
Expand Down
17 changes: 8 additions & 9 deletions src/Files.App/ViewModels/Properties/Items/FileProperties.cs
Original file line number Diff line number Diff line change
Expand Up @@ -134,15 +134,14 @@ public override async Task GetSpecialPropertiesAsync()
if (Item.IsShortcut)
return;

if (FileExtensionHelpers.IsBrowsableZipFile(Item.FileExtension, out _))
{
if (await ZipStorageFolder.FromPathAsync(Item.ItemPath) is ZipStorageFolder zipFolder)
{
var uncompressedSize = await zipFolder.GetUncompressedSize();
ViewModel.UncompressedItemSize = uncompressedSize.ToLongSizeString();
ViewModel.UncompressedItemSizeBytes = uncompressedSize;
}
}
if (Item.SyncStatusUI.SyncStatus is not CloudDriveSyncStatus.FileOnline and not CloudDriveSyncStatus.FolderOnline)
if (FileExtensionHelpers.IsBrowsableZipFile(Item.FileExtension, out _))
if (await ZipStorageFolder.FromPathAsync(Item.ItemPath) is ZipStorageFolder zipFolder)
{
var uncompressedSize = await zipFolder.GetUncompressedSize();
ViewModel.UncompressedItemSize = uncompressedSize.ToLongSizeString();
ViewModel.UncompressedItemSizeBytes = uncompressedSize;
}

if (file.Properties is not null)
GetOtherPropertiesAsync(file.Properties);
Expand Down
7 changes: 5 additions & 2 deletions src/Files.App/ViewModels/Properties/Items/FolderProperties.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,11 @@ public async override Task GetSpecialPropertiesAsync()
{
ViewModel.ItemSizeVisibility = true;
ViewModel.ItemSize = Item.FileSizeBytes.ToLongSizeString();
ViewModel.ItemSizeOnDisk = NativeFileOperationsHelper.GetFileSizeOnDisk(Item.ItemPath)?.ToLongSizeString() ??
string.Empty;

// Only load the size for items on the device
if (Item.SyncStatusUI.SyncStatus is not CloudDriveSyncStatus.FileOnline and not CloudDriveSyncStatus.FolderOnline)
ViewModel.ItemSizeOnDisk = NativeFileOperationsHelper.GetFileSizeOnDisk(Item.ItemPath)?.ToLongSizeString() ??
string.Empty;

ViewModel.ItemCreatedTimestampReal = Item.ItemDateCreatedReal;
ViewModel.ItemAccessedTimestampReal = Item.ItemDateAccessedReal;
Expand Down