From ea997defd0951ff13a8bd25508dd7d5c7247e400 Mon Sep 17 00:00:00 2001 From: Peter Holloway Date: Tue, 20 Oct 2026 19:43:28 +0100 Subject: [PATCH] Ignore tracker extensions that match instrument As the instrument name is used as the extension by default it doesn't make sense to store the same value for both. When updating a configuration, the field is skipped or reset if it matches but when creating a new configuration, the matching extension would still be set. This makes the behaviour consistent between updating a configuration and creating a new one. --- src/db_service.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/db_service.rs b/src/db_service.rs index 7975c78..1d3560f 100644 --- a/src/db_service.rs +++ b/src/db_service.rs @@ -248,7 +248,7 @@ impl DbInstrumentConfig { self.directory, self.scan, self.detector, - self.tracker_file_extension + self.tracker_file_extension.filter(|ext| ext != &self.name), ) .fetch_one(&db.pool) .await?; @@ -678,6 +678,14 @@ mod db_tests { assert!(ok!(upd.update_instrument(&db)).is_none()); } + #[tokio::test] + async fn extension_matching_instrument() { + let db = SqliteScanPathService::memory().await; + + let cfg = ok!(update("i22").with_extension("i22").insert_new(&db)); + assert_eq!(cfg.tracker_file_extension(), None) + } + #[tokio::test] async fn reset_file_extension() { let db = SqliteScanPathService::memory().await;