From 24375c24f3d7e2a161af6b7d376661cf955a5054 Mon Sep 17 00:00:00 2001 From: Fedor Korotkov Date: Tue, 10 May 2022 16:20:52 -0400 Subject: [PATCH] Print total size of compressed layers (#60) Before pulling an image. --- Sources/tart/VMDirectory+OCI.swift | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Sources/tart/VMDirectory+OCI.swift b/Sources/tart/VMDirectory+OCI.swift index 9784566..32c162e 100644 --- a/Sources/tart/VMDirectory+OCI.swift +++ b/Sources/tart/VMDirectory+OCI.swift @@ -52,8 +52,10 @@ extension VMDirectory { } // Progress - defaultLogger.appendNewLine("pulling disk...") - let progress = Progress(totalUnitCount: Int64(diskLayers.map{ $0.size }.reduce(0) { $0 + $1 })) + let diskCompressedSize: Int64 = Int64(diskLayers.map {$0.size}.reduce(0) {$0 + $1}) + let prettyDiskSize = String(format: "%.1f", Double(diskCompressedSize) / 1_000_000_000.0) + defaultLogger.appendNewLine("pulling disk (\(prettyDiskSize) GB compressed)...") + let progress = Progress(totalUnitCount: diskCompressedSize) ProgressObserver(progress).log(defaultLogger) for diskLayer in diskLayers {