diff --git a/Sources/tart/Commands/Prune.swift b/Sources/tart/Commands/Prune.swift index 39037d8..cab8eaf 100644 --- a/Sources/tart/Commands/Prune.swift +++ b/Sources/tart/Commands/Prune.swift @@ -16,6 +16,9 @@ struct Prune: AsyncParsableCommand { valueName: "n")) var cacheBudget: UInt? + @Flag(help: .hidden) + var gc: Bool = false + func validate() throws { if olderThan == nil && cacheBudget == nil { throw ValidationError("at least one criteria must be specified") @@ -24,6 +27,10 @@ struct Prune: AsyncParsableCommand { func run() async throws { do { + if gc { + try VMStorageOCI().gc() + } + // Clean up cache entries based on last accessed date if let olderThan = olderThan { let olderThanInterval = Int(exactly: olderThan)!.days.timeInterval diff --git a/Sources/tart/VMStorageOCI.swift b/Sources/tart/VMStorageOCI.swift index f9f616c..00e6ce1 100644 --- a/Sources/tart/VMStorageOCI.swift +++ b/Sources/tart/VMStorageOCI.swift @@ -166,6 +166,8 @@ class VMStorageOCI: PrunableStorage { } try FileManager.default.createSymbolicLink(at: vmURL(to), withDestinationURL: vmURL(from)) + + try gc() } }