@@ -113,7 +113,6 @@ class CommunityDownload extends _$CommunityDownload {
113113 await _persistFileMetadata (
114114 database,
115115 audioItemId: audioItemId,
116- localCollectionId: collection.id,
117116 file: subtitle.file,
118117 );
119118 await ref.read (audioLibraryProvider.notifier).loadLibrary ();
@@ -189,12 +188,7 @@ class CommunityDownload extends _$CommunityDownload {
189188 if (localCollection == null ) {
190189 throw StateError ('Community collection was removed during download' );
191190 }
192- await _persistFileMetadata (
193- database,
194- audioItemId: item.id,
195- localCollectionId: localCollection.id,
196- file: file,
197- );
191+ await _persistFileMetadata (database, audioItemId: item.id, file: file);
198192 await ref.read (audioLibraryProvider.notifier).loadLibrary ();
199193 await ref.read (collectionListProvider.notifier).loadCollections ();
200194 final srt = _toSrt (subtitle);
@@ -273,36 +267,26 @@ class CommunityDownload extends _$CommunityDownload {
273267 }
274268 }
275269
270+ /// 持久化文件详情中的音频元数据,不修改合集关联排序。
276271 Future <void > _persistFileMetadata (
277272 db.AppDatabase database, {
278273 required String audioItemId,
279- required String localCollectionId,
280274 required CommunityCollectionFile file,
281275 }) async {
282276 final duration = file.durationSec;
283- await database.transaction (() async {
284- await (database.update (
285- database.audioItems,
286- )..where ((table) => table.id.equals (audioItemId))).write (
287- db.AudioItemsCompanion (
288- name: Value (file.title),
289- totalDuration: duration == null
290- ? const Value .absent ()
291- : Value (duration),
292- originalDate: Value (file.publishedAt),
293- communityUnavailableAt: const Value (null ),
294- updatedAt: Value (DateTime .now ()),
295- ),
296- );
297- await (database.update (database.collectionAudioItems)..where (
298- (table) =>
299- table.collectionId.equals (localCollectionId) &
300- table.audioItemId.equals (audioItemId),
301- ))
302- .write (
303- db.CollectionAudioItemsCompanion (sortOrder: Value (file.sortOrder)),
304- );
305- });
277+ await (database.update (
278+ database.audioItems,
279+ )..where ((table) => table.id.equals (audioItemId))).write (
280+ db.AudioItemsCompanion (
281+ name: Value (file.title),
282+ totalDuration: duration == null
283+ ? const Value .absent ()
284+ : Value (duration),
285+ originalDate: Value (file.publishedAt),
286+ communityUnavailableAt: const Value (null ),
287+ updatedAt: Value (DateTime .now ()),
288+ ),
289+ );
306290 }
307291
308292 Future <void > _markFileUnavailable (
0 commit comments