Fix for decompressing zstd with localpath URL. (#512)

- InputSource(url:) rejects URLs with nil scheme, which was what was
passed when running the `container system kernel set` integration test
with a local kernel archive path.
This commit is contained in:
J Logan authored and GitHub committed 2026-02-02 20:32:07 -08:00
1 parent 258ad89d51
commit c3fe889a2f
1 file changed
+9 -2
@@ -103,7 +103,6 @@ public final class ArchiveReader {
/// Initialize the `ArchiveReader` to read from a specified file URL
/// by trying to auto determine the archives `Format` and `Filter`.
public init(file: URL) throws {
self.underlying = archive_read_new()
// Try to decompress as zstd first, fall back to original if it fails
@@ -128,7 +127,15 @@ public final class ArchiveReader {
/// Decompress a zstd file to a temporary location
private static func decompressZstd(_ source: URL) throws -> URL {
guard let inputStream = InputStream(url: source) else {
let inputStream: InputStream?
if source.scheme == nil || source.scheme == "" {
// can't use InputStream(url:) with nil scheme
inputStream = .init(fileAtPath: source.path)
} else {
inputStream = InputStream(url: source)
}
guard let inputStream else {
throw ArchiveError.noUnderlyingArchive
}
inputStream.open()