diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 63ed874..021b6e0 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -29,6 +29,7 @@ Table of Contents 1. Code should follow camel case 2. Code should follow [SwiftFormat](https://github.com/nicklockwood/SwiftFormat#swift-package-manager-plugin) guidelines. You can auto-format the code by running the following command: + ```bash swift package plugin --allow-writing-to-package-directory swiftformat --cache ignore . ``` diff --git a/Sources/tart/VMStorageOCI.swift b/Sources/tart/VMStorageOCI.swift index 5cd51f7..f71c547 100644 --- a/Sources/tart/VMStorageOCI.swift +++ b/Sources/tart/VMStorageOCI.swift @@ -27,12 +27,12 @@ class VMStorageOCI: PrunableStorage { return digest } - func open(_ name: RemoteName) throws -> VMDirectory { + func open(_ name: RemoteName, _ accessDate: Date = Date()) throws -> VMDirectory { let vmDir = VMDirectory(baseURL: vmURL(name)) try vmDir.validate(userFriendlyName: name.description) - try vmDir.baseURL.updateAccessDate() + try vmDir.baseURL.updateAccessDate(accessDate) return vmDir } @@ -180,6 +180,10 @@ class VMStorageOCI: PrunableStorage { let transaction = SentrySDK.startTransaction(name: name.description, operation: "pull", bindToScope: true) let tmpVMDir = try VMDirectory.temporaryDeterministic(key: name.description) + // Open an existing VM directory corresponding to this name, if any, + // marking it as outdated to speed up the garbage collection process + _ = try? open(name, Date(timeIntervalSince1970: 0)) + // Lock the temporary VM directory to prevent it's garbage collection let tmpVMDirLock = try FileLock(lockURL: tmpVMDir.baseURL) try tmpVMDirLock.lock()