mirror of
https://github.com/apple/container.git
synced 2026-09-28 01:46:25 -04:00
Update to containerization 0.42.0 (#2207)
Signed-off-by: Kathryn Baldauf <k_baldauf@apple.com>
This commit is contained in:
@@ -302,7 +302,7 @@ public actor ImagesService {
|
||||
for image in images {
|
||||
guard activeReferences.contains(image.reference) else { continue }
|
||||
activeCount += 1
|
||||
let imageDigest = image.digest.trimmingDigestPrefix
|
||||
let imageDigest = try image.digest.validatedDigestEncoding()
|
||||
guard processedDigests.insert(imageDigest).inserted else { continue }
|
||||
|
||||
for digest in try await image.referencedDigests() where activeContentSizes[digest] == nil {
|
||||
|
||||
@@ -80,7 +80,7 @@ public actor SnapshotStore {
|
||||
|
||||
for desc in toUnpack {
|
||||
try Task.checkCancellation()
|
||||
let snapshotDir = self.snapshotDir(desc)
|
||||
let snapshotDir = try self.snapshotDir(desc)
|
||||
guard !self.fm.fileExists(atPath: snapshotDir.absolutePath()) else {
|
||||
// We have already unpacked this image + platform. Skip
|
||||
continue
|
||||
@@ -110,7 +110,7 @@ public actor SnapshotStore {
|
||||
let mount = try await unpacker.unpack(image, for: platform, at: tempSnapshotPath, progress: progress)
|
||||
let fs = Filesystem.block(
|
||||
format: mount.type,
|
||||
source: self.snapshotPath(desc).absolutePath(),
|
||||
source: try self.snapshotPath(desc).absolutePath(),
|
||||
destination: mount.destination,
|
||||
options: mount.options
|
||||
)
|
||||
@@ -141,7 +141,7 @@ public actor SnapshotStore {
|
||||
toDelete = try await image.unpackableDescriptors()
|
||||
}
|
||||
for desc in toDelete {
|
||||
let p = self.snapshotDir(desc)
|
||||
let p = try self.snapshotDir(desc)
|
||||
guard self.fm.fileExists(atPath: p.absolutePath()) else {
|
||||
continue
|
||||
}
|
||||
@@ -151,8 +151,8 @@ public actor SnapshotStore {
|
||||
|
||||
public func get(for image: Containerization.Image, platform: Platform) async throws -> Filesystem {
|
||||
let desc = try await image.descriptor(for: platform)
|
||||
let infoPath = snapshotInfoPath(desc)
|
||||
let fsPath = snapshotPath(desc)
|
||||
let infoPath = try snapshotInfoPath(desc)
|
||||
let fsPath = try snapshotPath(desc)
|
||||
|
||||
guard self.fm.fileExists(atPath: infoPath.absolutePath()),
|
||||
self.fm.fileExists(atPath: fsPath.absolutePath())
|
||||
@@ -173,7 +173,7 @@ public actor SnapshotStore {
|
||||
continue
|
||||
}
|
||||
let desc = try await image.descriptor(for: platform)
|
||||
toKeep.append(desc.digest.trimmingDigestPrefix)
|
||||
toKeep.append(try desc.digest.validatedDigestEncoding())
|
||||
}
|
||||
}
|
||||
let all = try self.fm.contentsOfDirectory(at: self.path, includingPropertiesForKeys: [.totalFileAllocatedSizeKey]).map {
|
||||
@@ -192,19 +192,19 @@ public actor SnapshotStore {
|
||||
return deletedBytes
|
||||
}
|
||||
|
||||
private func snapshotDir(_ desc: Descriptor) -> URL {
|
||||
let p = self.path.appendingPathComponent(desc.digest.trimmingDigestPrefix, isDirectory: true)
|
||||
private func snapshotDir(_ desc: Descriptor) throws -> URL {
|
||||
let p = self.path.appendingPathComponent(try desc.digest.validatedDigestEncoding(), isDirectory: true)
|
||||
return p
|
||||
}
|
||||
|
||||
private func snapshotPath(_ desc: Descriptor) -> URL {
|
||||
let p = self.snapshotDir(desc)
|
||||
private func snapshotPath(_ desc: Descriptor) throws -> URL {
|
||||
let p = try self.snapshotDir(desc)
|
||||
.appendingPathComponent(Self.snapshotFileName, isDirectory: false)
|
||||
return p
|
||||
}
|
||||
|
||||
private func snapshotInfoPath(_ desc: Descriptor) -> URL {
|
||||
let p = self.snapshotDir(desc)
|
||||
private func snapshotInfoPath(_ desc: Descriptor) throws -> URL {
|
||||
let p = try self.snapshotDir(desc)
|
||||
.appendingPathComponent(Self.snapshotInfoFileName, isDirectory: false)
|
||||
return p
|
||||
}
|
||||
@@ -216,8 +216,8 @@ public actor SnapshotStore {
|
||||
}
|
||||
|
||||
/// Get the disk size for a specific snapshot descriptor
|
||||
public func getSnapshotSize(descriptor: Descriptor) -> UInt64 {
|
||||
let snapshotPath = self.snapshotDir(descriptor)
|
||||
public func getSnapshotSize(descriptor: Descriptor) throws -> UInt64 {
|
||||
let snapshotPath = try self.snapshotDir(descriptor)
|
||||
guard self.fm.fileExists(atPath: snapshotPath.path) else {
|
||||
return 0
|
||||
}
|
||||
@@ -228,9 +228,9 @@ public actor SnapshotStore {
|
||||
public func getSnapshotSizes(for image: Containerization.Image) async throws -> [(digest: String, size: UInt64)] {
|
||||
var results: [(digest: String, size: UInt64)] = []
|
||||
for descriptor in try await image.unpackableDescriptors() {
|
||||
let size = self.getSnapshotSize(descriptor: descriptor)
|
||||
let size = try self.getSnapshotSize(descriptor: descriptor)
|
||||
guard size > 0 else { continue }
|
||||
results.append((descriptor.digest.trimmingDigestPrefix, size))
|
||||
results.append((try descriptor.digest.validatedDigestEncoding(), size))
|
||||
}
|
||||
return results
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user