Skip to content

Commit 590fcba

Browse files
committed
Review comments
Signed-off-by: Aditya Ramani <a_ramani@apple.com>
1 parent 19cd45a commit 590fcba

File tree

2 files changed

+11
-14
lines changed

2 files changed

+11
-14
lines changed

Sources/Containerization/Image/Unpacker/EXT4Unpacker.swift

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -45,24 +45,21 @@ public struct EXT4Unpacker: Unpacker {
4545
try Task.checkCancellation()
4646
let content = try await image.getContent(digest: layer.digest)
4747

48+
let compression: ContainerizationArchive.Filter
4849
switch layer.mediaType {
4950
case MediaTypes.imageLayer, MediaTypes.dockerImageLayer:
50-
try filesystem.unpack(
51-
source: content.path,
52-
format: .paxRestricted,
53-
compression: .none,
54-
progress: progress
55-
)
51+
compression = .none
5652
case MediaTypes.imageLayerGzip, MediaTypes.dockerImageLayerGzip:
57-
try filesystem.unpack(
58-
source: content.path,
59-
format: .paxRestricted,
60-
compression: .gzip,
61-
progress: progress
62-
)
53+
compression = .gzip
6354
default:
6455
throw ContainerizationError(.unsupported, message: "Media type \(layer.mediaType) not supported.")
6556
}
57+
try filesystem.unpack(
58+
source: content.path,
59+
format: .paxRestricted,
60+
compression: compression,
61+
progress: progress
62+
)
6663
}
6764

6865
return .block(

Sources/cctl/ImageCommand.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ extension Application {
9999
@Option(name: .customLong("platform"), help: "Platform string in the form 'os/arch/variant'. Example 'linux/arm64/v8', 'linux/amd64'") var platformString: String?
100100

101101
@Option(
102-
name: .customLong("unpack-path"), help: "Path to unpack image into",
102+
name: .customLong("unpack-path"), help: "Path to a new directory to unpack the image into",
103103
transform: { str in
104104
URL(fileURLWithPath: str, relativeTo: .currentDirectory()).absoluteURL.path(percentEncoded: false)
105105
})
@@ -137,7 +137,7 @@ extension Application {
137137
return
138138
}
139139
guard !FileManager.default.fileExists(atPath: unpackPath) else {
140-
throw ContainerizationError(.invalidArgument, message: "File exists at \(unpackPath)")
140+
throw ContainerizationError(.exists, message: "Directory already exists at \(unpackPath)")
141141
}
142142
let unpackUrl = URL(filePath: unpackPath)
143143
try FileManager.default.createDirectory(at: unpackUrl, withIntermediateDirectories: true)

0 commit comments

Comments
 (0)