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
+2 -2
View File
@@ -1,12 +1,12 @@
{
"name": "ripster-backend",
"version": "0.11.0-4",
"version": "0.11.0-5",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "ripster-backend",
"version": "0.11.0-4",
"version": "0.11.0-5",
"dependencies": {
"archiver": "^7.0.1",
"cors": "^2.8.5",
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "ripster-backend",
"version": "0.11.0-4",
"version": "0.11.0-5",
"private": true,
"type": "commonjs",
"scripts": {
+15
View File
@@ -54,6 +54,21 @@ router.post(
})
);
router.post(
'/rescan-drive',
asyncHandler(async (req, res) => {
const devicePath = String(req.body?.devicePath || '').trim();
logger.info('post:rescan-drive', { reqId: req.reqId, devicePath });
if (!devicePath) {
const err = new Error('devicePath ist erforderlich');
err.statusCode = 400;
throw err;
}
const result = await diskDetectionService.rescanDriveAndEmit(devicePath);
res.json({ result });
})
);
router.get(
'/omdb/search',
asyncHandler(async (req, res) => {
+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