Files
SpotiFLAC-Mobile/lib/services/library_shadow_sql.dart
T
zarzet 12d33dd666 refactor(library): keep the shadow check SQL in a leaf file
album_completeness.dart and library_search.dart need only the shadow
table name and the shadow predicate, but imported all of
sqlite_helpers.dart (dart:io, path_provider, the sqflite FFI factory)
for them. Both now live in library_shadow_sql.dart, which
sqlite_helpers.dart re-exports, so the sqlite.libraryShadowTable and
sqlite.libraryNotShadowedSql names stay the same. No behavior change.
2026-10-31 01:20:41 +07:00

21 lines
833 B
Dart

/// TEMP pairs of a Library row and the History row whose path keys match it:
/// the scanned files a download already holds. `LibraryShadowSnapshot` in
/// sqlite_helpers.dart keeps it on the Library connection.
const libraryShadowTable = 'temp.library_shadowed';
/// The Library row [alias] is not shadowed by a downloaded History file.
/// [snapshot] reads [libraryShadowTable] instead of probing every path key
/// of the row; both select the same rows.
String libraryNotShadowedSql(String alias, {bool snapshot = false}) => snapshot
? '''
NOT EXISTS (
SELECT 1 FROM $libraryShadowTable shadow WHERE shadow.item_id = $alias.id
)'''
: '''
NOT EXISTS (
SELECT 1
FROM library_path_keys lpk
JOIN history_db.history_path_keys hpk ON hpk.path_key = lpk.path_key
WHERE lpk.item_id = $alias.id
)''';