0.11.0-1 queue fix

This commit is contained in:
2026-03-17 20:08:45 +00:00
parent 16c783e1aa
commit 56879d2e8d
13 changed files with 147 additions and 50 deletions
+69 -26
View File
@@ -572,6 +572,45 @@ function mapPresetEntriesToOptions(entries) {
return options;
}
/**
* Parses the drive_devices JSON setting into a normalized array of {path, makemkvIndex}.
* Supports both the legacy string format ["/dev/sr0"] and the object format
* [{"path": "/dev/sr0", "makemkvIndex": 0}].
* When makemkvIndex is missing, it is auto-derived from the device name (sr0→0, sr1→1).
*/
function parseDriveDeviceEntries(raw) {
try {
const arr = JSON.parse(raw || '[]');
if (!Array.isArray(arr)) {
return [];
}
return arr.map((entry) => {
if (typeof entry === 'string') {
const p = entry.trim();
if (!p) {
return null;
}
const m = p.match(/sr(\d+)$/);
return { path: p, makemkvIndex: m ? Number(m[1]) : 0 };
}
if (entry && typeof entry === 'object' && entry.path) {
const p = String(entry.path || '').trim();
if (!p) {
return null;
}
const idxRaw = entry.makemkvIndex != null ? Number(entry.makemkvIndex) : null;
const m = p.match(/sr(\d+)$/);
const derived = m ? Number(m[1]) : 0;
const idx = Number.isFinite(idxRaw) && idxRaw >= 0 ? Math.trunc(idxRaw) : derived;
return { path: p, makemkvIndex: idx };
}
return null;
}).filter(Boolean);
} catch (_error) {
return [];
}
}
class SettingsService {
constructor() {
this.settingsSnapshotCache = {
@@ -1192,21 +1231,12 @@ class SettingsService {
resolveHandBrakeSourceArg(map, deviceInfo = null) {
if (map.drive_mode === 'explicit') {
// Prefer drive_devices array, fall back to legacy drive_device
let explicitPaths = [];
try {
const parsed = JSON.parse(map.drive_devices || '[]');
if (Array.isArray(parsed)) {
explicitPaths = parsed.map((p) => String(p || '').trim()).filter(Boolean);
}
} catch (_error) {
// ignore parse error
}
const firstExplicit = explicitPaths[0] || String(map.drive_device || '').trim();
if (!firstExplicit) {
const entries = parseDriveDeviceEntries(map.drive_devices);
const firstPath = entries[0]?.path || String(map.drive_device || '').trim();
if (!firstPath) {
throw new Error('Kein Laufwerk konfiguriert, obwohl drive_mode=explicit gesetzt ist.');
}
return firstExplicit;
return firstPath;
}
const detectedPath = String(deviceInfo?.path || '').trim();
@@ -1214,15 +1244,10 @@ class SettingsService {
return detectedPath;
}
// Fallback: first explicit device, or legacy drive_device
try {
const parsed = JSON.parse(map.drive_devices || '[]');
if (Array.isArray(parsed) && parsed.length > 0) {
const first = String(parsed[0] || '').trim();
if (first) return first;
}
} catch (_error) {
// ignore
// Fallback: first configured device or legacy drive_device
const entries = parseDriveDeviceEntries(map.drive_devices);
if (entries.length > 0) {
return entries[0].path;
}
const configuredPath = String(map.drive_device || '').trim();
if (configuredPath) {
@@ -1385,10 +1410,28 @@ class SettingsService {
}
resolveSourceArg(map, deviceInfo = null) {
// Single-drive setup: always use MakeMKV's first logical disc device.
void map;
void deviceInfo;
return 'disc:0';
const devicePath = String(deviceInfo?.path || '').trim();
// In explicit mode: look up per-drive makemkvIndex from drive_devices
if (devicePath && map.drive_mode === 'explicit') {
const entries = parseDriveDeviceEntries(map.drive_devices);
const entry = entries.find((e) => e.path === devicePath);
if (entry) {
return `disc:${entry.makemkvIndex}`;
}
}
// Auto-derive from device name (/dev/sr0 → disc:0, /dev/sr1 → disc:1)
if (devicePath) {
const match = devicePath.match(/sr(\d+)$/);
if (match) {
return `disc:${match[1]}`;
}
}
// Fall back to global makemkv_source_index setting
const sourceIndex = Number(map.makemkv_source_index ?? 0);
return `disc:${Number.isFinite(sourceIndex) && sourceIndex >= 0 ? Math.trunc(sourceIndex) : 0}`;
}
async loadHandBrakePresetOptionsFromCli(map = {}) {