From bb9d2ce11f80d13f0f71fee504b0dca17278396c Mon Sep 17 00:00:00 2001 From: Agatha Lovelace Date: Sat, 24 Sep 2022 13:37:36 +0200 Subject: [PATCH] Make songs conflict on hash, not filename --- src/fetching.rs | 2 +- src/migrator/m20220815_000001_create_library.rs | 7 +------ 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/src/fetching.rs b/src/fetching.rs index 0289458..5993a1e 100644 --- a/src/fetching.rs +++ b/src/fetching.rs @@ -111,7 +111,7 @@ pub async fn index_source(source: Source, mode: IndexMode, db: &DatabaseConnecti library::Entity::insert(song) .on_conflict( - sea_query::OnConflict::column(library::Column::Filename) + sea_query::OnConflict::column(library::Column::Hash) .do_nothing() .to_owned(), ) diff --git a/src/migrator/m20220815_000001_create_library.rs b/src/migrator/m20220815_000001_create_library.rs index 28f202f..54a04ac 100644 --- a/src/migrator/m20220815_000001_create_library.rs +++ b/src/migrator/m20220815_000001_create_library.rs @@ -19,12 +19,7 @@ impl MigrationTrait for Migration { .primary_key(), ) .col(ColumnDef::new(Song::Path).string().not_null()) - .col( - ColumnDef::new(Song::Filename) - .string() - .not_null() - .unique_key(), - ) + .col(ColumnDef::new(Song::Filename).string().not_null()) .col(ColumnDef::new(Song::SourceId).integer().not_null()) .col(ColumnDef::new(Song::Hash).integer().not_null().unique_key()) .col(ColumnDef::new(Song::Artist).string())