documentation
CI / check (push) Successful in 1m29s
CI / docker (push) Successful in 1m57s

This commit is contained in:
Connor Johnstone
2026-03-23 16:17:01 -04:00
parent c7110fbbe7
commit 53b3a644a1
12 changed files with 1518 additions and 157 deletions
+10 -9
View File
@@ -44,20 +44,21 @@ impl LocalMusicBrainzFetcher {
/// Check whether the database has been populated with data.
pub fn is_available(&self) -> bool {
let conn = self.conn.lock().unwrap();
// Check if the mb_artists table exists and has rows
// Check if the mb_artists table exists and has at least one row.
// Use EXISTS (SELECT 1 ...) instead of COUNT(*) to avoid scanning the entire table.
conn.query_row(
"SELECT COUNT(*) FROM sqlite_master WHERE type='table' AND name='mb_artists'",
"SELECT EXISTS(SELECT 1 FROM sqlite_master WHERE type='table' AND name='mb_artists')",
[],
|row| row.get::<_, i32>(0),
|row| row.get::<_, bool>(0),
)
.map(|c| c > 0)
.unwrap_or(false)
&& conn
.query_row("SELECT COUNT(*) FROM mb_artists LIMIT 1", [], |row| {
row.get::<_, i32>(0)
})
.unwrap_or(0)
> 0
.query_row(
"SELECT EXISTS(SELECT 1 FROM mb_artists LIMIT 1)",
[],
|row| row.get::<_, bool>(0),
)
.unwrap_or(false)
}
/// Get statistics about the imported data.