0.11.0-5 multi lw
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user