WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Commit 07031cb

Browse files
author
thumb2086
committed
fix: prevent metadata corruption for weba and flac files
- Skip metadata writing for flac files to prevent file corruption - FLAC files have strict header requirements where writing metadata after download can corrupt the sync code and make files unplayable - Update download_manager_provider.dart to check for both weba and flac extensions - Update server/routes/playback.dart to check for both weba and flac extensions - Add explanatory comments documenting why metadata writing is skipped for these formats - Refactor extension checking to use variable assignment for clarity
1 parent b254ab6 commit 07031cb

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

lib/provider/download_manager_provider.dart

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,11 @@ class DownloadManagerNotifier extends Notifier<List<DownloadTask>> {
239239
return;
240240
}
241241

242-
if (container.getFileExtension() == "weba") return;
242+
// Skip metadata writing for weba and flac to prevent file corruption
243+
// FLAC files have strict header requirements and writing metadata after
244+
// download can corrupt the sync code and make files unplayable
245+
final extension = container.getFileExtension();
246+
if (extension == "weba" || extension == "flac") return;
243247

244248
final imageBytes = await ServiceUtils.downloadImage(
245249
(task.track.album.images).asUrlString(

lib/provider/server/routes/playback.dart

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,11 @@ class ServerPlaybackRoutes {
247247

248248
await trackPartialCacheFile.rename(trackCacheFile.path);
249249

250-
if (track.qualityPreset!.getFileExtension() == "weba") return;
250+
// Skip metadata writing for weba and flac to prevent file corruption
251+
// FLAC files have strict header requirements and writing metadata after
252+
// download can corrupt the sync code and make files unplayable
253+
final extension = track.qualityPreset!.getFileExtension();
254+
if (extension == "weba" || extension == "flac") return;
251255

252256
final imageBytes = await ServiceUtils.downloadImage(
253257
track.query.album.images.asUrlString(

0 commit comments

Comments
 (0)