fix(download): verify ReplayGain tags independently of metadata embedding

This commit is contained in:
zarzet committed 2026-09-30 20:58:18 +07:00
1 parent 2538cdffe1
commit fb08110797
2 files changed
+9 -6

No files matched your search

@@ -922,7 +922,8 @@ object NativeDownloadFinalizer {
}
val deleteScanPath = scanPath != state.filePath
val scan = try {
scanReplayGain(scanPath, shouldCancel) ?: return null
scanReplayGain(scanPath, shouldCancel)
?: throw IllegalStateException("ReplayGain analysis produced no valid measurement")
} finally {
if (deleteScanPath) File(scanPath).delete()
}
@@ -453,6 +453,10 @@ extension _DownloadQueueEmbedding on DownloadQueueNotifier {
_log.d(
'Metadata embedding disabled, skipping $format metadata/cover embed',
);
if (settings.embedReplayGain) {
final rg = await ReplayGainService.scanAndApplyToFile(filePath);
if (rg != null) _storeTrackReplayGainForAlbum(track, filePath, rg);
}
return null;
}
@@ -827,12 +831,10 @@ extension _DownloadQueueEmbedding on DownloadQueueNotifier {
if (settings.embedReplayGain) {
try {
final rgResult = await FFmpegService.scanReplayGain(filePath);
final rgResult = await ReplayGainService.scanAndApplyToFile(
filePath,
);
if (rgResult != null) {
await PlatformBridge.editFileMetadata(filePath, {
'replaygain_track_gain': rgResult.trackGain,
'replaygain_track_peak': rgResult.trackPeak,
});
_log.d(
'ReplayGain for $format: gain=${rgResult.trackGain}, peak=${rgResult.trackPeak}',
);