From 0c6cb2e21042d36663c763ecd001f056b59a727a Mon Sep 17 00:00:00 2001 From: Maximilian Bauer Date: Tue, 14 May 2024 22:05:19 +0200 Subject: [PATCH] Cache: fix artwork types --- AmperfyKit/Storage/CacheFileManager.swift | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/AmperfyKit/Storage/CacheFileManager.swift b/AmperfyKit/Storage/CacheFileManager.swift index fa8b2264..90658e4a 100644 --- a/AmperfyKit/Storage/CacheFileManager.swift +++ b/AmperfyKit/Storage/CacheFileManager.swift @@ -44,6 +44,9 @@ public class CacheFileManager { if createDirectoryIfNeeded(at: subDir) { try? markItemAsExcludedFromBackup(at: subDir) } + if fileManager.fileExists(atPath: to.path) { + try? self.removeItem(at: to) + } try fileManager.moveItem(at: at, to: to) try markItemAsExcludedFromBackup(at: to) } @@ -141,7 +144,11 @@ public class CacheFileManager { public func createRelPath(for artwork: Artwork) -> URL? { guard !artwork.managedObject.id.isEmpty else { return nil } - return Self.artworksDir.appendingPathComponent(artwork.managedObject.id) + if !artwork.type.isEmpty { + return Self.artworksDir.appendingPathComponent(artwork.type).appendingPathComponent(artwork.managedObject.id) + } else { + return Self.artworksDir.appendingPathComponent(artwork.managedObject.id) + } } public func createRelPath(for embeddedArtwork: EmbeddedArtwork) -> URL? {