Added the import/cleanup functionality
CI / check (push) Failing after 43s
CI / docker (push) Has been skipped

This commit is contained in:
Connor Johnstone
2026-03-24 15:58:14 -04:00
parent 929772512e
commit 49d1d2252e
6 changed files with 18 additions and 4 deletions
+8
View File
@@ -69,6 +69,9 @@ pub struct TaggingConfig {
#[serde(default = "default_confidence")] #[serde(default = "default_confidence")]
pub confidence: f64, pub confidence: f64,
#[serde(default = "default_tag_concurrency")]
pub concurrency: usize,
} }
#[derive(Debug, Clone, Serialize, Deserialize)] #[derive(Debug, Clone, Serialize, Deserialize)]
@@ -243,10 +246,15 @@ impl Default for TaggingConfig {
auto_tag: false, auto_tag: false,
write_tags: true, write_tags: true,
confidence: default_confidence(), confidence: default_confidence(),
concurrency: default_tag_concurrency(),
} }
} }
} }
fn default_tag_concurrency() -> usize {
4
}
impl Default for DownloadConfig { impl Default for DownloadConfig {
fn default() -> Self { fn default() -> Self {
Self { Self {
+6
View File
@@ -715,6 +715,9 @@ pub fn run_import(
PRAGMA foreign_keys = OFF;", PRAGMA foreign_keys = OFF;",
)?; )?;
// Wrap entire import in a transaction so interrupted imports don't leave empty tables
conn.execute_batch("BEGIN;")?;
let mut stats = ImportStats::default(); let mut stats = ImportStats::default();
// Import artists // Import artists
@@ -818,6 +821,9 @@ pub fn run_import(
rusqlite::params![stats.recordings.to_string()], rusqlite::params![stats.recordings.to_string()],
)?; )?;
// Commit the transaction — if we got here, everything succeeded
conn.execute_batch("COMMIT;")?;
progress(&format!("Import complete: {stats}")); progress(&format!("Import complete: {stats}"));
Ok(stats) Ok(stats)
} }