Retag queued Matroska files in place instead of converting to MP4

The queue now mirrors the document window for .mkv/.mka/.mks sources.
The window's whole save branching (importer-order track snapshot, chapter
row snapshot, staleness guard, tag-writer-vs-remuxer choice) moved out of
Document into a shared MatroskaSaver used by both Document and QueueItem
so the two paths cannot drift. Queue items import tags-only, keep the
Matroska extension (in place, or stream-copy into a destination folder),
MP4-only actions no-op on them, and send-to-queue hands the item the
document's model plus its identity pairing baseline via attachMatroskaSaver.

Co-Authored-By: Claude Code <noreply@anthropic.com>
This commit is contained in:
Scott GarrettandClaude Code committed 2026-11-29 20:33:47 -05:00
1 parent a1da1c8106
commit 80ca3970ec
7 files changed
+442 -195

No files matched your search

+20 -1
View File
@@ -236,7 +236,7 @@ final class QueueController : NSWindowController, NSWindowDelegate, NSPopoverDel
updateUI(indexes: IndexSet(integer: queue.index(of: item)))
DispatchQueue.global().async {
if originalStatus != .completed {
if originalStatus != .completed, item.isMatroska == false {
do {
try item.prepare()
} catch {
@@ -251,6 +251,13 @@ final class QueueController : NSWindowController, NSWindowDelegate, NSPopoverDel
var doc: Document?
if originalStatus == .completed {
try doc = Document(contentsOf: item.destURL, ofType: "")
} else if item.isMatroska {
// Open the source file instead of the item's model:
// only the document's own MKV read sets up a complete
// tags-only Matroska document (Document.readMatroska
// builds the pairing/staleness baseline the save
// writes back through).
try doc = Document(contentsOf: item.fileURL, ofType: "")
} else if let mp4 = item.mp4File {
doc = Document(mp4: mp4)
}
@@ -277,6 +284,18 @@ final class QueueController : NSWindowController, NSWindowDelegate, NSPopoverDel
//MARK: Items creation
private func destination(for url: URL) -> URL {
// Matroska files are retagged in their own container by the queue
// (matching the window's save), so the extension must survive: the
// file itself when no destination folder is set (in-place retag), or
// the same name in the folder (a stream-copy remux writes it there,
// the queue equivalent of Save-As).
if MP42FileImporter.isMatroskaFileType(url.pathExtension) {
if let destination = prefs.destination {
return destination.appendingPathComponent(url.lastPathComponent)
}
return url
}
let value = try? url.resourceValues(forKeys: [URLResourceKey.typeIdentifierKey])
var isMpeg4 = false