diff --git a/lib/providers/local_library_provider.dart b/lib/providers/local_library_provider.dart index 5d4af06c..62e9b56a 100644 --- a/lib/providers/local_library_provider.dart +++ b/lib/providers/local_library_provider.dart @@ -33,7 +33,6 @@ class LocalLibraryState { final int excludedDownloadedCount; final Set _trackKeySet; final Set _isrcSet; - final Map _filePathById; LocalLibraryState({ this.isScanning = false, @@ -50,10 +49,8 @@ class LocalLibraryState { this.excludedDownloadedCount = 0, Set? trackKeySet, Set? isrcSet, - Map? filePathById, }) : _trackKeySet = trackKeySet ?? const {}, - _isrcSet = isrcSet ?? const {}, - _filePathById = filePathById ?? const {}; + _isrcSet = isrcSet ?? const {}; bool hasIsrc(String isrc) => _isrcSet.contains(isrc); @@ -62,8 +59,6 @@ class LocalLibraryState { return _trackKeySet.contains(key); } - String? filePathForId(String id) => _filePathById[id]; - bool existsInLibrary({String? isrc, String? trackName, String? artistName}) { if (isrc != null && isrc.isNotEmpty && hasIsrc(isrc)) { return true; @@ -89,7 +84,6 @@ class LocalLibraryState { int? excludedDownloadedCount, Set? trackKeySet, Set? isrcSet, - Map? filePathById, }) { return LocalLibraryState( isScanning: isScanning ?? this.isScanning, @@ -107,7 +101,6 @@ class LocalLibraryState { excludedDownloadedCount ?? this.excludedDownloadedCount, trackKeySet: trackKeySet ?? _trackKeySet, isrcSet: isrcSet ?? _isrcSet, - filePathById: filePathById ?? _filePathById, ); } } @@ -190,7 +183,6 @@ class LocalLibraryNotifier extends Notifier { excludedDownloadedCount: excludedDownloadedCount, trackKeySet: lookupIndex.matchKeys, isrcSet: lookupIndex.isrcs, - filePathById: lookupIndex.filePathById, ); _log.i( 'Loaded local library summary: $count items, lastScannedAt: ' @@ -227,7 +219,6 @@ class LocalLibraryNotifier extends Notifier { excludedDownloadedCount: excludedDownloadedCount, trackKeySet: index.matchKeys, isrcSet: index.isrcs, - filePathById: index.filePathById, ); _hasLoadedFromDatabase = true; _isLoaded = true; diff --git a/lib/services/library_database.dart b/lib/services/library_database.dart index cf2ae3ba..56e7b86a 100644 --- a/lib/services/library_database.dart +++ b/lib/services/library_database.dart @@ -208,12 +208,24 @@ class LocalLibraryAlbumGroup { class LocalLibraryLookupIndex { final Set isrcs; final Set matchKeys; - final Map filePathById; const LocalLibraryLookupIndex({ this.isrcs = const {}, this.matchKeys = const {}, - this.filePathById = const {}, + }); +} + +class LocalLibraryBatchLookupRequest { + final String? id; + final String? isrc; + final String trackName; + final String artistName; + + const LocalLibraryBatchLookupRequest({ + this.id, + this.isrc, + required this.trackName, + required this.artistName, }); } @@ -1644,18 +1656,10 @@ class LibraryDatabase { Future getLookupIndex() async { final db = await database; - final rows = await db.rawQuery( - 'SELECT id, file_path, isrc, match_key FROM library', - ); + final rows = await db.rawQuery('SELECT isrc, match_key FROM library'); final isrcs = {}; final matchKeys = {}; - final filePathById = {}; for (final row in rows) { - final id = row['id'] as String?; - final filePath = row['file_path'] as String?; - if (id != null && id.isNotEmpty && filePath != null) { - filePathById[id] = filePath; - } final isrc = row['isrc'] as String?; if (isrc != null && isrc.isNotEmpty) { isrcs.add(isrc); @@ -1668,7 +1672,6 @@ class LibraryDatabase { return LocalLibraryLookupIndex( isrcs: Set.unmodifiable(isrcs), matchKeys: Set.unmodifiable(matchKeys), - filePathById: Map.unmodifiable(filePathById), ); }