From f9874ea32ee1b2b9221b7f9d5dde7b8cb6974510 Mon Sep 17 00:00:00 2001 From: Yair <39923744+yaira2@users.noreply.github.com> Date: Sun, 26 Nov 2023 13:38:49 -0500 Subject: [PATCH 1/5] Fix: Fixed some null ref warnings in decompress helper --- .../Content/Archives/Decompress/DecompressArchive.cs | 3 +++ src/Files.App/Utils/Archives/DecompressHelper.cs | 12 ++++++------ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/Files.App/Actions/Content/Archives/Decompress/DecompressArchive.cs b/src/Files.App/Actions/Content/Archives/Decompress/DecompressArchive.cs index 329af11425f5..208f8d203ac3 100644 --- a/src/Files.App/Actions/Content/Archives/Decompress/DecompressArchive.cs +++ b/src/Files.App/Actions/Content/Archives/Decompress/DecompressArchive.cs @@ -23,6 +23,9 @@ public DecompressArchive() public override Task ExecuteAsync() { + if (context.ShellPage is null) + return Task.CompletedTask; + return DecompressHelper.DecompressArchiveAsync(context.ShellPage); } diff --git a/src/Files.App/Utils/Archives/DecompressHelper.cs b/src/Files.App/Utils/Archives/DecompressHelper.cs index c0465b4c2e71..c7f6e7e2abe1 100644 --- a/src/Files.App/Utils/Archives/DecompressHelper.cs +++ b/src/Files.App/Utils/Archives/DecompressHelper.cs @@ -128,11 +128,11 @@ public static async Task DecompressArchiveAsync(IShellPage associatedInstance) if (associatedInstance == null) return; - BaseStorageFile archive = await StorageHelpers.ToStorageItem(associatedInstance.SlimContentPage.SelectedItems.Count != 0 + BaseStorageFile archive = await StorageHelpers.ToStorageItem(associatedInstance?.SlimContentPage?.SelectedItems?.Count != 0 ? associatedInstance.SlimContentPage.SelectedItem.ItemPath : associatedInstance.FilesystemViewModel.WorkingDirectory); - if (archive is null) + if (archive.Path is null) return; var isArchiveEncrypted = await FilesystemTasks.Wrap(() => DecompressHelper.IsArchiveEncrypted(archive)); @@ -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) @@ -186,7 +186,7 @@ public static async Task DecompressArchiveHereAsync(IShellPage associatedInstanc BaseStorageFile archive = await StorageHelpers.ToStorageItem(selectedItem.ItemPath); BaseStorageFolder currentFolder = await StorageHelpers.ToStorageItem(associatedInstance.FilesystemViewModel.CurrentFolder.ItemPath); - if (archive is null) + if (archive.Path is null) return; if (await FilesystemTasks.Wrap(() => IsArchiveEncrypted(archive))) @@ -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) @@ -227,7 +227,7 @@ public static async Task DecompressArchiveToChildFolderAsync(IShellPage associat BaseStorageFolder currentFolder = await StorageHelpers.ToStorageItem(associatedInstance.FilesystemViewModel.CurrentFolder.ItemPath); BaseStorageFolder destinationFolder = null; - if (archive is null) + if (archive.Path is null) return; if (await FilesystemTasks.Wrap(() => DecompressHelper.IsArchiveEncrypted(archive))) From ada034b5273a39901e0db78830065bb9229cef83 Mon Sep 17 00:00:00 2001 From: Yair <39923744+yaira2@users.noreply.github.com> Date: Mon, 27 Nov 2023 10:14:01 -0500 Subject: [PATCH 2/5] Update src/Files.App/Utils/Archives/DecompressHelper.cs Co-authored-by: hishitetsu <66369541+hishitetsu@users.noreply.github.com> --- src/Files.App/Utils/Archives/DecompressHelper.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Files.App/Utils/Archives/DecompressHelper.cs b/src/Files.App/Utils/Archives/DecompressHelper.cs index c7f6e7e2abe1..c88ed1b1f9cf 100644 --- a/src/Files.App/Utils/Archives/DecompressHelper.cs +++ b/src/Files.App/Utils/Archives/DecompressHelper.cs @@ -128,9 +128,9 @@ public static async Task DecompressArchiveAsync(IShellPage associatedInstance) if (associatedInstance == null) return; - BaseStorageFile archive = await StorageHelpers.ToStorageItem(associatedInstance?.SlimContentPage?.SelectedItems?.Count != 0 - ? associatedInstance.SlimContentPage.SelectedItem.ItemPath - : associatedInstance.FilesystemViewModel.WorkingDirectory); + BaseStorageFile archive = await StorageHelpers.ToStorageItem(associatedInstance.SlimContentPage?.SelectedItems?.Count is null or 0 + ? associatedInstance.FilesystemViewModel.WorkingDirectory + : associatedInstance.SlimContentPage.SelectedItem.ItemPath); if (archive.Path is null) return; From 56607f1da7cfb5c3259e46d066eea4e42cd068ce Mon Sep 17 00:00:00 2001 From: Yair <39923744+yaira2@users.noreply.github.com> Date: Mon, 27 Nov 2023 10:14:08 -0500 Subject: [PATCH 3/5] Update src/Files.App/Utils/Archives/DecompressHelper.cs Co-authored-by: hishitetsu <66369541+hishitetsu@users.noreply.github.com> --- src/Files.App/Utils/Archives/DecompressHelper.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Files.App/Utils/Archives/DecompressHelper.cs b/src/Files.App/Utils/Archives/DecompressHelper.cs index c88ed1b1f9cf..ab550678394f 100644 --- a/src/Files.App/Utils/Archives/DecompressHelper.cs +++ b/src/Files.App/Utils/Archives/DecompressHelper.cs @@ -132,7 +132,7 @@ public static async Task DecompressArchiveAsync(IShellPage associatedInstance) ? associatedInstance.FilesystemViewModel.WorkingDirectory : associatedInstance.SlimContentPage.SelectedItem.ItemPath); - if (archive.Path is null) + if (archive?.Path is null) return; var isArchiveEncrypted = await FilesystemTasks.Wrap(() => DecompressHelper.IsArchiveEncrypted(archive)); From da0051d72fe2ba60f545999eddeacb9e5ba0fc5d Mon Sep 17 00:00:00 2001 From: Yair <39923744+yaira2@users.noreply.github.com> Date: Mon, 27 Nov 2023 10:14:16 -0500 Subject: [PATCH 4/5] Update src/Files.App/Utils/Archives/DecompressHelper.cs Co-authored-by: hishitetsu <66369541+hishitetsu@users.noreply.github.com> --- src/Files.App/Utils/Archives/DecompressHelper.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Files.App/Utils/Archives/DecompressHelper.cs b/src/Files.App/Utils/Archives/DecompressHelper.cs index ab550678394f..8d248cd057ed 100644 --- a/src/Files.App/Utils/Archives/DecompressHelper.cs +++ b/src/Files.App/Utils/Archives/DecompressHelper.cs @@ -186,7 +186,7 @@ public static async Task DecompressArchiveHereAsync(IShellPage associatedInstanc BaseStorageFile archive = await StorageHelpers.ToStorageItem(selectedItem.ItemPath); BaseStorageFolder currentFolder = await StorageHelpers.ToStorageItem(associatedInstance.FilesystemViewModel.CurrentFolder.ItemPath); - if (archive.Path is null) + if (archive?.Path is null) return; if (await FilesystemTasks.Wrap(() => IsArchiveEncrypted(archive))) From 9494a146b2c9075834ae478cd117ceca0c5e6f64 Mon Sep 17 00:00:00 2001 From: Yair <39923744+yaira2@users.noreply.github.com> Date: Mon, 27 Nov 2023 10:14:22 -0500 Subject: [PATCH 5/5] Update src/Files.App/Utils/Archives/DecompressHelper.cs Co-authored-by: hishitetsu <66369541+hishitetsu@users.noreply.github.com> --- src/Files.App/Utils/Archives/DecompressHelper.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Files.App/Utils/Archives/DecompressHelper.cs b/src/Files.App/Utils/Archives/DecompressHelper.cs index 8d248cd057ed..eb78df6f1c69 100644 --- a/src/Files.App/Utils/Archives/DecompressHelper.cs +++ b/src/Files.App/Utils/Archives/DecompressHelper.cs @@ -227,7 +227,7 @@ public static async Task DecompressArchiveToChildFolderAsync(IShellPage associat BaseStorageFolder currentFolder = await StorageHelpers.ToStorageItem(associatedInstance.FilesystemViewModel.CurrentFolder.ItemPath); BaseStorageFolder destinationFolder = null; - if (archive.Path is null) + if (archive?.Path is null) return; if (await FilesystemTasks.Wrap(() => DecompressHelper.IsArchiveEncrypted(archive)))