From 842d99e12b7a43d866e788a45f714f886e895036 Mon Sep 17 00:00:00 2001 From: Arlo Godfrey Date: Wed, 3 Apr 2024 15:26:24 -0500 Subject: [PATCH] Fixed an issue where ZipArchiveFolder.DeleteAsync wasn't handling files correctly. --- src/OwlCore.Storage.csproj | 15 +++++++++++---- src/System/IO/Compression/ZipArchiveFolder.cs | 12 ++++++++++++ .../OwlCore.Storage.Tests.csproj | 6 +++--- 3 files changed, 26 insertions(+), 7 deletions(-) diff --git a/src/OwlCore.Storage.csproj b/src/OwlCore.Storage.csproj index a6ba445..1791420 100644 --- a/src/OwlCore.Storage.csproj +++ b/src/OwlCore.Storage.csproj @@ -14,7 +14,7 @@ $(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb Arlo Godfrey - 0.10.0 + 0.10.1 OwlCore The most flexible file system abstraction, ever. Built in partnership with the UWP Community. @@ -23,6 +23,13 @@ LICENSE.txt logo.png +--- 0.10.1 --- +[Fixes] +Fixed an issue where ZipArchiveFolder.DeleteAsync wasn't handling files correctly. + +[Improvements] +Update all dependencies to latest versions. + --- 0.10.0 --- THIS IS A BREAKING RELEASE Update asap, and do not use older versions or implementations. @@ -254,9 +261,9 @@ Initial release of OwlCore.Storage. - - - + + + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/src/System/IO/Compression/ZipArchiveFolder.cs b/src/System/IO/Compression/ZipArchiveFolder.cs index ce33e9b..ffd7c26 100644 --- a/src/System/IO/Compression/ZipArchiveFolder.cs +++ b/src/System/IO/Compression/ZipArchiveFolder.cs @@ -117,11 +117,23 @@ public async Task DeleteAsync(IStorableChild item, CancellationToken cancellatio { var entry = TryGetEntry(readOnlyFolder.Path); + if (entry is null) + throw new FileNotFoundException("The item was not found in the folder."); + + entry.Delete(); + } + else if (item is ZipArchiveEntryFile file) + { + var entry = TryGetEntry(file.Name); if (entry is null) throw new FileNotFoundException("The item was not found in the folder."); else entry.Delete(); } + else + { + throw new ArgumentException("The item is not a valid child of this folder.", nameof(item)); + } } /// diff --git a/tests/OwlCore.Storage.Tests/OwlCore.Storage.Tests.csproj b/tests/OwlCore.Storage.Tests/OwlCore.Storage.Tests.csproj index 37fda26..3bdec7d 100644 --- a/tests/OwlCore.Storage.Tests/OwlCore.Storage.Tests.csproj +++ b/tests/OwlCore.Storage.Tests/OwlCore.Storage.Tests.csproj @@ -11,8 +11,8 @@ - - + + all runtime; build; native; contentfiles; analyzers; buildtransitive @@ -20,7 +20,7 @@ - +