Skip to content

Commit 8782681

Browse files
committed
big fuckup
1 parent edb8e27 commit 8782681

10 files changed

Lines changed: 50 additions & 78 deletions

docs/en-US/Get-ZipEntry.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ Archive 2/22/2024 1:19 PM 1.55 KB 5.35 KB Set-ZipEnt
127127

128128
```powershell
129129
PS ..\pwsh> $package = Invoke-WebRequest https://www.powershellgallery.com/api/v2/package/PSCompression
130-
PS ..\pwsh> $package | Get-ZipEntry
130+
PS ..\pwsh> $package | Get-ZipEntry | Select-Object -First 5
131131
132132
Directory: /
133133

src/PSCompression/Commands/ConvertFromGzipStringCommand.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@ protected override void ProcessRecord()
4545
WriteObject(reader.ReadLine());
4646
}
4747
}
48+
catch (Exception _) when (_ is PipelineStoppedException or FlowControlException)
49+
{
50+
throw;
51+
}
4852
catch (Exception exception)
4953
{
5054
WriteError(exception.ToEnumerationError(line));

src/PSCompression/Commands/ConvertToGzipStringCommand.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,10 @@ protected override void EndProcessing()
8080

8181
WriteObject(Convert.ToBase64String(_outstream.ToArray()));
8282
}
83+
catch (Exception _) when (_ is PipelineStoppedException or FlowControlException)
84+
{
85+
throw;
86+
}
8387
catch (Exception exception)
8488
{
8589
WriteError(exception.ToWriteError(_outstream));

src/PSCompression/Commands/ExpandGzipArchiveCommand.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,10 @@ protected override void ProcessRecord()
150150
encoding: Encoding,
151151
cmdlet: this);
152152
}
153+
catch (Exception _) when (_ is PipelineStoppedException or FlowControlException)
154+
{
155+
throw;
156+
}
153157
catch (Exception exception)
154158
{
155159
WriteError(exception.ToOpenError(path));

src/PSCompression/Commands/ExpandZipEntryCommand.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@ protected override void BeginProcessing()
3434
if (Destination.IsArchive())
3535
{
3636
ThrowTerminatingError(
37-
ExceptionHelper.NotDirectoryPath(Destination, nameof(Destination)));
37+
ExceptionHelper.NotDirectoryPath(
38+
Destination,
39+
nameof(Destination)));
3840
}
3941

4042
if (!Directory.Exists(Destination))
@@ -67,6 +69,10 @@ protected override void ProcessRecord()
6769
WriteObject(new DirectoryInfo(path));
6870
}
6971
}
72+
catch (Exception _) when (_ is PipelineStoppedException or FlowControlException)
73+
{
74+
throw;
75+
}
7076
catch (Exception exception)
7177
{
7278
WriteError(exception.ToExtractEntryError(entry));

src/PSCompression/Commands/GetZipEntryCommand.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,10 @@ ZipEntryBase CreateFromStream(ZipArchiveEntry entry, bool isDirectory) =>
8686
WriteObject(entries, enumerateCollection: true);
8787
return;
8888
}
89+
catch (Exception _) when (_ is PipelineStoppedException or FlowControlException)
90+
{
91+
throw;
92+
}
8993
catch (InvalidDataException exception)
9094
{
9195
ThrowTerminatingError(exception.ToInvalidZipArchive());
@@ -122,6 +126,10 @@ ZipEntryBase CreateFromFile(ZipArchiveEntry entry, bool isDirectory) =>
122126

123127
WriteObject(entries, enumerateCollection: true);
124128
}
129+
catch (Exception _) when (_ is PipelineStoppedException or FlowControlException)
130+
{
131+
throw;
132+
}
125133
catch (InvalidDataException exception)
126134
{
127135
ThrowTerminatingError(exception.ToInvalidZipArchive());

src/PSCompression/Commands/GetZipEntryContentCommand.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ protected override void ProcessRecord()
4242
ZipContentReader reader = new(GetOrAdd(entry));
4343
ReadEntry(entry, reader);
4444
}
45+
catch (Exception _) when (_ is PipelineStoppedException or FlowControlException)
46+
{
47+
throw;
48+
}
4549
catch (Exception exception)
4650
{
4751
WriteError(exception.ToOpenError(entry.Source));

src/PSCompression/Commands/NewZipEntryCommand.cs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,9 @@ protected override void BeginProcessing()
103103
if (!SourcePath.IsArchive())
104104
{
105105
ThrowTerminatingError(
106-
ExceptionHelper.NotArchivePath(SourcePath, nameof(SourcePath)));
106+
ExceptionHelper.NotArchivePath(
107+
SourcePath,
108+
nameof(SourcePath)));
107109
}
108110

109111
using FileStream fileStream = File.Open(
@@ -136,6 +138,10 @@ protected override void BeginProcessing()
136138
compressionLevel: CompressionLevel));
137139
}
138140
}
141+
catch (Exception _) when (_ is PipelineStoppedException or FlowControlException)
142+
{
143+
throw;
144+
}
139145
catch (Exception exception)
140146
{
141147
ThrowTerminatingError(exception.ToOpenError(Destination));
@@ -185,6 +191,10 @@ protected override void EndProcessing()
185191
_zip?.Dispose();
186192
WriteObject(GetResult(), enumerateCollection: true);
187193
}
194+
catch (Exception _) when (_ is PipelineStoppedException or FlowControlException)
195+
{
196+
throw;
197+
}
188198
catch (Exception exception)
189199
{
190200
ThrowTerminatingError(exception.ToOpenError(Destination));

src/PSCompression/Commands/RemoveZipEntryCommand.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
namespace PSCompression.Commands;
77

88
[Cmdlet(VerbsCommon.Remove, "ZipEntry", SupportsShouldProcess = true)]
9+
[OutputType(typeof(void))]
910
public sealed class RemoveZipEntryCommand : PSCmdlet, IDisposable
1011
{
1112
private readonly ZipArchiveCache _cache = new(ZipArchiveMode.Update);
@@ -24,6 +25,10 @@ protected override void ProcessRecord()
2425
entry.Remove(_cache.GetOrAdd(entry));
2526
}
2627
}
28+
catch (Exception _) when (_ is PipelineStoppedException or FlowControlException)
29+
{
30+
throw;
31+
}
2732
catch (NotSupportedException exception)
2833
{
2934
ThrowTerminatingError(exception.ToStreamOpenError(entry));

src/PSCompression/Extensions/PathExtensions.cs

Lines changed: 2 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -19,79 +19,6 @@ public static class PathExtensions
1919

2020
private const string _directorySeparator = "/";
2121

22-
// [ThreadStatic]
23-
// private static List<string>? s_normalizedPaths;
24-
25-
// internal static string[] NormalizePath(
26-
// this string[] paths,
27-
// bool isLiteral,
28-
// PSCmdlet cmdlet,
29-
// bool throwOnInvalidProvider = false)
30-
// {
31-
// s_normalizedPaths ??= [];
32-
// Collection<string> resolvedPaths;
33-
// ProviderInfo provider;
34-
// s_normalizedPaths.Clear();
35-
36-
// foreach (string path in paths)
37-
// {
38-
// if (isLiteral)
39-
// {
40-
// string resolvedPath = cmdlet
41-
// .SessionState.Path
42-
// .GetUnresolvedProviderPathFromPSPath(path, out provider, out _);
43-
44-
// if (!provider.IsFileSystem())
45-
// {
46-
// if (throwOnInvalidProvider)
47-
// {
48-
// cmdlet.ThrowTerminatingError(provider.ToInvalidProviderError(path));
49-
// }
50-
51-
// cmdlet.WriteError(provider.ToInvalidProviderError(path));
52-
// continue;
53-
// }
54-
55-
// s_normalizedPaths.Add(resolvedPath);
56-
// continue;
57-
// }
58-
59-
// try
60-
// {
61-
// resolvedPaths = cmdlet.GetResolvedProviderPathFromPSPath(path, out provider);
62-
63-
// foreach (string resolvedPath in resolvedPaths)
64-
// {
65-
// if (!provider.IsFileSystem())
66-
// {
67-
// cmdlet.WriteError(provider.ToInvalidProviderError(resolvedPath));
68-
// continue;
69-
// }
70-
71-
// s_normalizedPaths.Add(resolvedPath);
72-
// }
73-
// }
74-
// catch (Exception exception)
75-
// {
76-
77-
// cmdlet.WriteError(exception.ToResolvePathError(path));
78-
// }
79-
// }
80-
81-
// return [.. s_normalizedPaths];
82-
// }
83-
84-
// internal static string NormalizePath(
85-
// this string path,
86-
// bool isLiteral,
87-
// PSCmdlet cmdlet,
88-
// bool throwOnInvalidProvider = false) =>
89-
// NormalizePath([path], isLiteral, cmdlet, throwOnInvalidProvider)
90-
// .FirstOrDefault();
91-
92-
// internal static bool IsFileSystem(this ProviderInfo provider) =>
93-
// provider.ImplementingType == typeof(FileSystemProvider);
94-
9522
internal static string ResolvePath(this string path, PSCmdlet cmdlet)
9623
{
9724
string resolved = cmdlet.SessionState.Path.GetUnresolvedProviderPathFromPSPath(
@@ -150,6 +77,6 @@ internal static bool IsDirectoryPath(this string path) =>
15077

15178
public static string NormalizePath(this string path) =>
15279
s_reEntryDir.IsMatch(path)
153-
? NormalizeEntryPath(path)
154-
: NormalizeFileEntryPath(path);
80+
? NormalizeEntryPath(path)
81+
: NormalizeFileEntryPath(path);
15582
}

0 commit comments

Comments
 (0)