fix: add cdparanoia fallback for audio CD detection in VMs

udevadm media flags are not propagated in VM/passthrough scenarios.
When blkid and udevadm both return nothing, try cdparanoia -Q to
detect audio CDs directly via TOC read.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-12 08:18:55 +00:00
parent 871e39bba2
commit 15f1a49378

View File

@@ -539,6 +539,19 @@ class DiskDetectionService extends EventEmitter {
// udevadm not available or failed ignore
}
// Last resort: cdparanoia can read the TOC of audio CDs directly.
// Useful when udev media flags are not propagated (e.g. VM passthrough).
// blkid already returned nothing above, so a successful cdparanoia -Q
// means an audio CD is present (data discs have no filesystem but blkid
// would still have caught them via sector probing).
try {
await execFileAsync('cdparanoia', ['-Q', '-d', devicePath], { timeout: 10000 });
logger.debug('cdparanoia:audio-cd', { devicePath });
return { hasMedia: true, type: 'audio_cd' };
} catch (_cdError) {
// cdparanoia failed no audio CD present (or cdparanoia not installed)
}
logger.debug('blkid:no-media-or-fail', { devicePath });
return { hasMedia: false, type: null };
}