From d6c96507ca9fa47e559a15e33e6bb2a7e2670f4e Mon Sep 17 00:00:00 2001 From: Calvin Buckley Date: Sun, 31 Dec 2023 15:56:54 -0400 Subject: [PATCH] Fix using wrong cover path attribute I don't know why these are separate to begin with. It may be worth storing all of this in Core Data directly, and not using either path attribute, instead of trying to unify them... --- Submariner/SBCover.swift | 4 +++- Submariner/SBImportOperation.swift | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/Submariner/SBCover.swift b/Submariner/SBCover.swift index 1e1c800..82436d7 100644 --- a/Submariner/SBCover.swift +++ b/Submariner/SBCover.swift @@ -69,7 +69,9 @@ public class SBCover: SBMusicItem { let baseCoverDir = SBAppDelegate.coverDirectory self.willAccessValue(forKey: "imagePath") let currentPath = self.primitiveValue(forKey: "imagePath") as! NSString? - if let currentPath = currentPath { + // XXX: SBImportOperation was setting this, but SBSubsonicParsingOperation was not + let fallbackPath = self.primitiveValue(forKey: "path") as! NSString? + if let currentPath = currentPath ?? fallbackPath { if currentPath.isAbsolutePath { if let coversDir = coversDir(baseCoverDir.path as NSString) { // If the path matches the prefix, do it, otherwise move the file diff --git a/Submariner/SBImportOperation.swift b/Submariner/SBImportOperation.swift index eb149f0..2311e84 100644 --- a/Submariner/SBImportOperation.swift +++ b/Submariner/SBImportOperation.swift @@ -210,7 +210,7 @@ import UniformTypeIdentifiers if newAlbum!.cover == nil { newAlbum!.cover = SBCover.init(entity: SBCover.entity(), insertInto: threadedContext) } - newAlbum!.cover!.path = relativePath + newAlbum!.cover!.imagePath = relativePath as NSString? newAlbum!.cover!.isLocal = NSNumber(booleanLiteral: true) } else { // else if track parent directory contains cover file @@ -239,7 +239,7 @@ import UniformTypeIdentifiers if newAlbum!.cover == nil { newAlbum!.cover = SBCover.init(entity: SBCover.entity(), insertInto: threadedContext) } - newAlbum!.cover!.path = relativePath + newAlbum!.cover!.imagePath = relativePath newAlbum!.cover!.isLocal = NSNumber(booleanLiteral: true) // Don't set the track cover, since it's not really used. }