Skip to content

Commit

Permalink
Fix using wrong cover path attribute
Browse files Browse the repository at this point in the history
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...
  • Loading branch information
NattyNarwhal committed Dec 31, 2023
1 parent fdbffad commit d6c9650
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 3 additions & 1 deletion Submariner/SBCover.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions Submariner/SBImportOperation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
}
Expand Down

0 comments on commit d6c9650

Please sign in to comment.