mirror of
https://github.com/cirruslabs/tart.git
synced 2026-10-08 15:11:11 +02:00
Run garbage collection after each symlink and expose --gc in tart prune (#191)
This commit is contained in:
@@ -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()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user