Skip to content

Commit

Permalink
fix partial paths works
Browse files Browse the repository at this point in the history
Signed-off-by: Joseph Mattiello <git@joemattiello.com>
  • Loading branch information
JoeMatt committed Dec 3, 2024
1 parent 7dadcf5 commit 2f25fc9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -362,30 +362,28 @@ public final class ROMLocationMigrator {
continue
}

let currentPath = file.relativePath
let currentPath = file.partialPath
DLOG("Checking path for game \(game.title): \(currentPath)")

let romsPrefix = Paths.romsPath.lastPathComponent + "/"
// Check if path needs fixing
if !currentPath.hasPrefix("ROMs/") {
if !currentPath.hasPrefix(romsPrefix) || currentPath.contains("Container"){
// If it starts with the system ID, add ROMs/ prefix
if currentPath.hasPrefix(game.systemIdentifier + "/") {
let newPath = "ROMs/" + currentPath
let newPath = romsPrefix + currentPath
DLOG("Fixing path: \(currentPath) -> \(newPath)")

try realm.write {
let newFile = PVFile(withPartialPath: newPath)
game.file = newFile
game.file.partialPath = newPath
}
fixCount += 1
ILOG("Fixed partial path for \(game.title)")
} else {
// If it's just a filename, add full path
let newPath = "ROMs/\(game.systemIdentifier)/\(currentPath)"
let newPath = "\(romsPrefix)\(game.systemIdentifier)/\(file.url.lastPathComponent)"
DLOG("Fixing path: \(currentPath) -> \(newPath)")

try realm.write {
let newFile = PVFile(withPartialPath: newPath)
game.file = newFile
game.file.partialPath = newPath
}
fixCount += 1
ILOG("Fixed partial path for \(game.title)")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class PVFile: Object, LocalFileProvider, Codable, DomainConvertibleType {
public typealias DomainType = LocalFile

nonisolated(unsafe)
internal dynamic var partialPath: String = ""
public dynamic var partialPath: String = ""
nonisolated(unsafe)
internal dynamic var md5Cache: String?
// @objc private dynamic var crcCache: String?
Expand Down

0 comments on commit 2f25fc9

Please sign in to comment.