0.12.0-18 Tests and Converter Fixes
This commit is contained in:
@@ -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 }
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user