0.11.0-5 multi lw

This commit is contained in:
2026-03-17 21:57:44 +00:00
parent 38fc1778f7
commit d00191324b
12 changed files with 356 additions and 106 deletions
+59 -1
View File
@@ -464,7 +464,65 @@ class DiskDetectionService extends EventEmitter {
return results.filter(Boolean);
}
return this.detectAllAuto();
// Auto mode: scan all ROM drives via lsblk
const autoResults = await this.detectAllAuto();
// Fallback: if lsblk found no ROM drives but drive_device is configured, try it directly
if (autoResults.length === 0) {
const legacy = String(settingsMap.drive_device || '').trim();
if (legacy) {
logger.debug('detect:auto:lsblk-empty-fallback-explicit', { legacy });
const legacyResult = await this.detectExplicit(legacy);
if (legacyResult) {
return [legacyResult];
}
}
}
return autoResults;
}
// Rescan a single specific drive and emit the appropriate event
async rescanDriveAndEmit(devicePath) {
const normalized = this.normalizeDevicePath(devicePath);
if (!normalized) {
return { present: false, emitted: 'none', device: null };
}
try {
logger.info('rescan-drive:requested', { devicePath: normalized });
const detected = await this.detectExplicit(normalized);
const previouslyTracked = this.detectedDiscs.has(normalized);
if (detected) {
const previous = this.detectedDiscs.get(normalized);
const changed = previous ? buildSignature(previous) !== buildSignature(detected) : false;
this.detectedDiscs.set(normalized, detected);
this.lastDetected = detected;
this.lastPresent = true;
logger.info('rescan-drive:inserted', { devicePath: normalized, changed });
this.emit('discInserted', detected);
return { present: true, emitted: 'discInserted', device: detected };
}
// No disc found
if (previouslyTracked) {
const old = this.detectedDiscs.get(normalized);
this.detectedDiscs.delete(normalized);
if (this.detectedDiscs.size === 0) {
this.lastDetected = null;
this.lastPresent = false;
}
logger.info('rescan-drive:removed', { devicePath: normalized });
this.emit('discRemoved', old || { path: normalized });
return { present: false, emitted: 'discRemoved', device: null };
}
logger.info('rescan-drive:empty', { devicePath: normalized });
return { present: false, emitted: 'none', device: null };
} catch (error) {
logger.error('rescan-drive:error', { devicePath: normalized, error: errorToMeta(error) });
throw error;
}
}
// Multi-drive: tracks per-device state and emits insert/remove events for each