From a3f73cf1f80f6b43173ca8e77fe1e370f1646c50 Mon Sep 17 00:00:00 2001 From: Damiano Galassi Date: Sat, 3 Oct 2026 20:23:18 +0200 Subject: [PATCH] Add missing classes to actions decoder Fix #163. --- Classes/Queue.swift | 1 + Classes/QueueItem.swift | 17 ++++++++++++----- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/Classes/Queue.swift b/Classes/Queue.swift index f6f10a7..0aa8a18 100644 --- a/Classes/Queue.swift +++ b/Classes/Queue.swift @@ -54,6 +54,7 @@ final class Queue { } unarchiver.finishDecoding() } catch { + self.logger.writeError(toLog: error) items = [] } diff --git a/Classes/QueueItem.swift b/Classes/QueueItem.swift index dc69707..fe010b6 100644 --- a/Classes/QueueItem.swift +++ b/Classes/QueueItem.swift @@ -415,8 +415,8 @@ import MP42Foundation statusInternal = QueueItem.Status(rawValue: Int(aDecoder.decodeInt32(forKey: "SBQueueItemStatus"))) ?? .failed mp4File = aDecoder.decodeObject(of: [MP42File.classForCoder()], forKey: "SBQueueItemMp4File") as? MP42File - uniqueID = aDecoder.decodeObject(of: [NSString.classForCoder()], forKey: "SBQueueItemID") as! String - attributes = aDecoder.decodeObject(of: [NSDictionary.classForCoder(), NSString.classForCoder(), NSNumber.classForCoder()], forKey: "SBQueueItemAttributes") as! [String : Any] + uniqueID = aDecoder.decodeObject(of: [NSString.classForCoder()], forKey: "SBQueueItemID") as? String ?? UUID().uuidString + attributes = aDecoder.decodeObject(of: [NSDictionary.classForCoder(), NSString.classForCoder(), NSNumber.classForCoder()], forKey: "SBQueueItemAttributes") as? [String : Any] ?? [:] #if SB_SANDBOX if var bookmark = aDecoder.decodeObject(of: [NSData.classForCoder()], forKey: "SBQueueItemFileURLBookmark") as? Data { @@ -449,8 +449,14 @@ import MP42Foundation return nil } #else - fileURL = aDecoder.decodeObject(of: [NSURL.classForCoder()], forKey: "SBQueueItemFileURL") as! URL - destURLInternal = aDecoder.decodeObject(of: [NSURL.classForCoder()], forKey: "SBQueueItemDestURL") as! URL + if let fileURL = aDecoder.decodeObject(of: [NSURL.classForCoder()], forKey: "SBQueueItemFileURL") as? URL, + let destURLInternal = aDecoder.decodeObject(of: [NSURL.classForCoder()], forKey: "SBQueueItemDestURL") as? URL { + self.fileURL = fileURL + self.destURLInternal = destURLInternal + } else { + return nil + } + #endif actionsInternal = aDecoder.decodeObject(of: [NSArray.classForCoder(), QueueSetAction.classForCoder(), @@ -460,7 +466,8 @@ import MP42Foundation QueueRenameChaptersAction.classForCoder(), QueueOrganizeGroupsAction.classForCoder(), QueueColorSpaceAction.classForCoder(), QueueSetOutputFilenameAction.classForCoder(), QueueClearExistingMetadataAction.classForCoder(), - QueueOptimizeAction.classForCoder(), QueueSendToiTunesAction.classForCoder()], forKey: "SBQueueItemActions") as! [QueueActionProtocol] + QueueOptimizeAction.classForCoder(), QueueSendToiTunesAction.classForCoder(), + QueueChangeAudioLanguageAction.classForCoder(), QueueChangeSubtitleLanguageAction.classForCoder()], forKey: "SBQueueItemActions") as? [QueueActionProtocol] ?? [] } }