Run garbage collection after each symlink and expose --gc in tart prune (#191)

This commit is contained in:
Nikolay Edigaryev 2022-08-23 17:31:02 +04:00 committed by GitHub
parent 9e69c8c161
commit 732c8244a4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 0 deletions

View File

@ -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

View File

@ -166,6 +166,8 @@ class VMStorageOCI: PrunableStorage {
}
try FileManager.default.createSymbolicLink(at: vmURL(to), withDestinationURL: vmURL(from))
try gc()
}
}