From 2692c5cff4c499a22fffe11f8f145c19be18f7d9 Mon Sep 17 00:00:00 2001 From: J Logan Date: Tue, 31 Mar 2026 14:48:31 -0700 Subject: [PATCH] Removes unused `Archiver.uncompress()`. (#1372) - Nothing uses this function, and it does not perform secure extraction. Clients should instead use the `ArchiveReader` from the ContainerizationArchive library. --- .../ContainerAPIService/Client/Archiver.swift | 87 ------------------- 1 file changed, 87 deletions(-) diff --git a/Sources/Services/ContainerAPIService/Client/Archiver.swift b/Sources/Services/ContainerAPIService/Client/Archiver.swift index d20fb632..870670f6 100644 --- a/Sources/Services/ContainerAPIService/Client/Archiver.swift +++ b/Sources/Services/ContainerAPIService/Client/Archiver.swift @@ -108,93 +108,6 @@ public final class Archiver: Sendable { return hasher.finalize() } - public static func uncompress(source: URL, destination: URL) throws { - let source = source.standardizedFileURL - let destination = destination.standardizedFileURL - - // TODO: ArchiveReader needs some enhancement to support buffered uncompression - let reader = try ArchiveReader( - format: .paxRestricted, - filter: .gzip, - file: source - ) - - for (entry, data) in reader { - guard let path = entry.path else { - continue - } - let uncompressPath = destination.appendingPathComponent(path) - - let fileManager = FileManager.default - switch entry.fileType { - case .blockSpecial, .characterSpecial, .socket: - continue - case .directory: - try fileManager.createDirectory( - at: uncompressPath, - withIntermediateDirectories: true, - attributes: [ - FileAttributeKey.posixPermissions: entry.permissions - ] - ) - case .regular: - try fileManager.createDirectory( - at: uncompressPath.deletingLastPathComponent(), - withIntermediateDirectories: true, - attributes: [ - FileAttributeKey.posixPermissions: 0o755 - ] - ) - let success = fileManager.createFile( - atPath: uncompressPath.path, - contents: data, - attributes: [ - FileAttributeKey.posixPermissions: entry.permissions - ] - ) - if !success { - throw POSIXError.fromErrno() - } - try data.write(to: uncompressPath) - case .symbolicLink: - guard let target = entry.symlinkTarget else { - continue - } - try fileManager.createDirectory( - at: uncompressPath.deletingLastPathComponent(), - withIntermediateDirectories: true, - attributes: [ - FileAttributeKey.posixPermissions: 0o755 - ] - ) - try fileManager.createSymbolicLink(atPath: uncompressPath.path, withDestinationPath: target) - continue - default: - continue - } - - // FIXME: uid/gid for compress. - try fileManager.setAttributes( - [.posixPermissions: NSNumber(value: entry.permissions)], - ofItemAtPath: uncompressPath.path - ) - - if let creationDate = entry.creationDate { - try fileManager.setAttributes( - [.creationDate: creationDate], - ofItemAtPath: uncompressPath.path - ) - } - - if let modificationDate = entry.modificationDate { - try fileManager.setAttributes( - [.modificationDate: modificationDate], - ofItemAtPath: uncompressPath.path - ) - } - } - } - // MARK: private functions private static func _compressFile(item: URL, entry: WriteEntry, archiver: ArchiveWriter, hasher: inout SHA256) throws { guard let stream = InputStream(url: item) else {