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 some null ref warnings in decompress helper #14086

Merged
merged 5 commits into from
Nov 27, 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
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ public DecompressArchive()

public override Task ExecuteAsync()
{
if (context.ShellPage is null)
return Task.CompletedTask;

return DecompressHelper.DecompressArchiveAsync(context.ShellPage);
}

Expand Down
16 changes: 8 additions & 8 deletions src/Files.App/Utils/Archives/DecompressHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,11 @@ public static async Task DecompressArchiveAsync(IShellPage associatedInstance)
if (associatedInstance == null)
return;

BaseStorageFile archive = await StorageHelpers.ToStorageItem<BaseStorageFile>(associatedInstance.SlimContentPage.SelectedItems.Count != 0
? associatedInstance.SlimContentPage.SelectedItem.ItemPath
: associatedInstance.FilesystemViewModel.WorkingDirectory);
BaseStorageFile archive = await StorageHelpers.ToStorageItem<BaseStorageFile>(associatedInstance.SlimContentPage?.SelectedItems?.Count is null or 0
? associatedInstance.FilesystemViewModel.WorkingDirectory
: associatedInstance.SlimContentPage.SelectedItem.ItemPath);

if (archive is null)
if (archive?.Path is null)
return;

var isArchiveEncrypted = await FilesystemTasks.Wrap(() => DecompressHelper.IsArchiveEncrypted(archive));
Expand Down Expand Up @@ -177,7 +177,7 @@ public static async Task DecompressArchiveAsync(IShellPage associatedInstance)

public static async Task DecompressArchiveHereAsync(IShellPage associatedInstance)
{
if (associatedInstance?.SlimContentPage == null)
if (associatedInstance?.SlimContentPage?.SelectedItems == null)
return;

foreach (var selectedItem in associatedInstance.SlimContentPage.SelectedItems)
Expand All @@ -186,7 +186,7 @@ public static async Task DecompressArchiveHereAsync(IShellPage associatedInstanc
BaseStorageFile archive = await StorageHelpers.ToStorageItem<BaseStorageFile>(selectedItem.ItemPath);
BaseStorageFolder currentFolder = await StorageHelpers.ToStorageItem<BaseStorageFolder>(associatedInstance.FilesystemViewModel.CurrentFolder.ItemPath);

if (archive is null)
if (archive?.Path is null)
return;

if (await FilesystemTasks.Wrap(() => IsArchiveEncrypted(archive)))
Expand Down Expand Up @@ -216,7 +216,7 @@ public static async Task DecompressArchiveHereAsync(IShellPage associatedInstanc

public static async Task DecompressArchiveToChildFolderAsync(IShellPage associatedInstance)
{
if (associatedInstance?.SlimContentPage == null)
if (associatedInstance?.SlimContentPage?.SelectedItems == null)
return;

foreach (var selectedItem in associatedInstance.SlimContentPage.SelectedItems)
Expand All @@ -227,7 +227,7 @@ public static async Task DecompressArchiveToChildFolderAsync(IShellPage associat
BaseStorageFolder currentFolder = await StorageHelpers.ToStorageItem<BaseStorageFolder>(associatedInstance.FilesystemViewModel.CurrentFolder.ItemPath);
BaseStorageFolder destinationFolder = null;

if (archive is null)
if (archive?.Path is null)
return;

if (await FilesystemTasks.Wrap(() => DecompressHelper.IsArchiveEncrypted(archive)))
Expand Down