0.12.0-18 Tests and Converter Fixes

This commit is contained in:
2026-03-31 12:51:32 +00:00
parent aea8fa6772
commit 5aa65ad4c1
24 changed files with 2281 additions and 249 deletions
+43 -11
View File
@@ -339,7 +339,13 @@ class ConverterPlugin extends SourcePlugin {
cmd: handBrakeConfig.cmd, args: handBrakeConfig.args,
jobId: job?.id,
progressParser: parseHandBrakeProgress,
onProgress: (pct, statusText) => ctx.emitProgress(Math.round(pct), statusText || `Encoding ${pct}%`),
onProgress: (pct, statusText, eta) => ctx.emitProgress(
Math.round(pct),
statusText || `Encoding ${pct}%`,
eta ?? null
),
appendLogLine: ctx?.extra?.appendLogLine,
logSource: 'HANDBRAKE',
isCancelled,
onProcessHandle,
context: { jobId: job?.id, source: 'ConverterPlugin.encode', stage: 'ENCODING' }
@@ -451,6 +457,8 @@ class ConverterPlugin extends SourcePlugin {
await _spawnAndWait({
cmd: encodeConfig.cmd, args: encodeConfig.args,
jobId: job?.id,
appendLogLine: ctx?.extra?.appendLogLine,
logSource: 'FFMPEG',
isCancelled,
onProcessHandle,
context: { jobId: job?.id, source: 'ConverterPlugin.encode', stage: 'ENCODING' }
@@ -504,6 +512,8 @@ class ConverterPlugin extends SourcePlugin {
await _spawnAndWait({
cmd: encodeConfig.cmd, args: encodeConfig.args,
jobId: job?.id,
appendLogLine: ctx?.extra?.appendLogLine,
logSource: 'FFMPEG',
isCancelled,
onProcessHandle,
context: { jobId: job?.id, source: 'ConverterPlugin.encode', stage: 'ENCODING' }
@@ -536,6 +546,8 @@ class ConverterPlugin extends SourcePlugin {
await _spawnAndWait({
cmd: encodeConfig.cmd, args: encodeConfig.args,
jobId: job?.id,
appendLogLine: ctx?.extra?.appendLogLine,
logSource: 'FFMPEG',
isCancelled,
onProcessHandle,
context: { jobId: job?.id, source: 'ConverterPlugin.encode', stage: 'ENCODING' }
@@ -591,25 +603,45 @@ class ConverterPlugin extends SourcePlugin {
}
}
async function _spawnAndWait({ cmd, args, jobId, progressParser, onProgress, isCancelled, onProcessHandle, context }) {
async function _spawnAndWait({
cmd,
args,
jobId,
progressParser,
onProgress,
appendLogLine,
logSource = 'PROCESS',
isCancelled,
onProcessHandle,
context
}) {
if (typeof isCancelled === 'function' && isCancelled()) {
const err = new Error('Job wurde vom Benutzer abgebrochen.');
err.statusCode = 409;
throw err;
}
const handleLine = (stream, line) => {
if (progressParser && typeof onProgress === 'function') {
const progress = progressParser(line);
if (progress?.percent != null) {
onProgress(progress.percent, progress.detail || null, progress.eta ?? null);
}
}
if (typeof appendLogLine === 'function') {
try {
appendLogLine(logSource, line, stream);
} catch (_error) {
// ignore log append errors in process stream
}
}
};
const handle = spawnTrackedProcess({
cmd,
args,
onStdoutLine: () => {},
onStderrLine: (line) => {
if (progressParser && typeof onProgress === 'function') {
const progress = progressParser(line);
if (progress?.percent != null) {
onProgress(progress.percent, progress.detail || null);
}
}
},
onStdoutLine: (line) => handleLine('stdout', line),
onStderrLine: (line) => handleLine('stderr', line),
context: context || { jobId }
});