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 {