mirror of https://github.com/cirruslabs/tart.git
Run garbage collection after each symlink and expose --gc in tart prune (#191)
This commit is contained in:
parent
9e69c8c161
commit
732c8244a4
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -166,6 +166,8 @@ class VMStorageOCI: PrunableStorage {
|
|||
}
|
||||
|
||||
try FileManager.default.createSymbolicLink(at: vmURL(to), withDestinationURL: vmURL(from))
|
||||
|
||||
try gc()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue