From f9ac994e18b5fc17b3a589a1ecb8361405c081eb Mon Sep 17 00:00:00 2001 From: Nikolay Edigaryev Date: Fri, 16 Dec 2022 01:18:33 +0400 Subject: [PATCH] Fix inverted VMStorageOCI.link() logic (#355) --- Sources/tart/VMStorageOCI.swift | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Sources/tart/VMStorageOCI.swift b/Sources/tart/VMStorageOCI.swift index afbfd09..be26ec2 100644 --- a/Sources/tart/VMStorageOCI.swift +++ b/Sources/tart/VMStorageOCI.swift @@ -191,7 +191,7 @@ class VMStorageOCI: PrunableStorage { if name != digestName { // Create new or overwrite the old symbolic link - try link(from: digestName, to: name) + try link(from: name, to: digestName) } else { // Ensure that images pulled by content digest // are excluded from garbage collection @@ -200,11 +200,11 @@ class VMStorageOCI: PrunableStorage { } func link(from: RemoteName, to: RemoteName) throws { - if FileManager.default.fileExists(atPath: vmURL(to).path) { - try FileManager.default.removeItem(at: vmURL(to)) + if FileManager.default.fileExists(atPath: vmURL(from).path) { + try FileManager.default.removeItem(at: vmURL(from)) } - try FileManager.default.createSymbolicLink(at: vmURL(to), withDestinationURL: vmURL(from)) + try FileManager.default.createSymbolicLink(at: vmURL(from), withDestinationURL: vmURL(to)) try gc() }