From bbe0bd1bb787fc885b74b2149a72cdbfc3f7a083 Mon Sep 17 00:00:00 2001 From: Jamie Pine <32987599+jamiepine@users.noreply.github.com> Date: Mon, 16 Oct 2023 20:54:41 -0700 Subject: [PATCH] [END-1309] Fix explorer query invalidation (#1604) fix --- core/src/api/files.rs | 4 ++++ core/src/location/indexer/shallow.rs | 1 + core/src/location/manager/watcher/utils.rs | 11 ++++++++++- core/src/location/mod.rs | 1 + core/src/object/file_identifier/shallow.rs | 1 + core/src/object/media/media_processor/shallow.rs | 1 + 6 files changed, 18 insertions(+), 1 deletion(-) diff --git a/core/src/api/files.rs b/core/src/api/files.rs index 3adc7a350..a8610f3f4 100644 --- a/core/src/api/files.rs +++ b/core/src/api/files.rs @@ -258,6 +258,7 @@ pub(crate) fn mount() -> AlphaRouter { .await?; invalidate_query!(library, "search.paths"); + invalidate_query!(library, "search.objects"); Ok(()) }) }) @@ -274,6 +275,7 @@ pub(crate) fn mount() -> AlphaRouter { .exec() .await?; + invalidate_query!(library, "search.objects"); invalidate_query!(library, "search.paths"); Ok(()) }) @@ -479,6 +481,7 @@ pub(crate) fn mount() -> AlphaRouter { fs::remove_file(path.as_ref()).await.map_err(|e| { // Let's also invalidate the query here, because we succeeded in converting the file invalidate_query!(library, "search.paths"); + invalidate_query!(library, "search.objects"); FileIOError::from(( path.as_ref(), @@ -489,6 +492,7 @@ pub(crate) fn mount() -> AlphaRouter { } invalidate_query!(library, "search.paths"); + invalidate_query!(library, "search.objects"); Ok(()) }) diff --git a/core/src/location/indexer/shallow.rs b/core/src/location/indexer/shallow.rs index 048b41bac..110a0a9b2 100644 --- a/core/src/location/indexer/shallow.rs +++ b/core/src/location/indexer/shallow.rs @@ -186,6 +186,7 @@ pub async fn shallow( .map_err(IndexerError::from)?; invalidate_query!(library, "search.paths"); + invalidate_query!(library, "search.objects"); } library.orphan_remover.invoke().await; diff --git a/core/src/location/manager/watcher/utils.rs b/core/src/location/manager/watcher/utils.rs index 0cc82606f..d0db96d92 100644 --- a/core/src/location/manager/watcher/utils.rs +++ b/core/src/location/manager/watcher/utils.rs @@ -131,6 +131,7 @@ pub(super) async fn create_dir( scan_location_sub_path(node, library, location, &children_materialized_path).await?; invalidate_query!(library, "search.paths"); + invalidate_query!(library, "search.objects"); Ok(()) } @@ -319,6 +320,7 @@ async fn inner_create_file( } invalidate_query!(library, "search.paths"); + invalidate_query!(library, "search.objects"); Ok(()) } @@ -365,7 +367,10 @@ pub(super) async fn update_file( ) .await } - .map(|_| invalidate_query!(library, "search.paths")) + .map(|_| { + invalidate_query!(library, "search.paths"); + invalidate_query!(library, "search.objects"); + }) } async fn inner_update_file( @@ -572,6 +577,7 @@ async fn inner_update_file( } invalidate_query!(library, "search.paths"); + invalidate_query!(library, "search.objects"); } Ok(()) @@ -664,6 +670,7 @@ pub(super) async fn rename( .await?; invalidate_query!(library, "search.paths"); + invalidate_query!(library, "search.objects"); } Ok(()) @@ -741,6 +748,7 @@ pub(super) async fn remove_by_file_path( } invalidate_query!(library, "search.paths"); + invalidate_query!(library, "search.objects"); Ok(()) } @@ -845,6 +853,7 @@ pub(super) async fn recalculate_directories_size( if should_invalidate { invalidate_query!(library, "search.paths"); + invalidate_query!(library, "search.objects"); } candidates.extend(buffer.drain(..)); diff --git a/core/src/location/mod.rs b/core/src/location/mod.rs index d926a953d..cea4d7029 100644 --- a/core/src/location/mod.rs +++ b/core/src/location/mod.rs @@ -781,6 +781,7 @@ pub async fn delete_directory( library.orphan_remover.invoke().await; invalidate_query!(library, "search.paths"); + invalidate_query!(library, "search.objects"); Ok(()) } diff --git a/core/src/object/file_identifier/shallow.rs b/core/src/object/file_identifier/shallow.rs index e580831d2..9d545a18f 100644 --- a/core/src/object/file_identifier/shallow.rs +++ b/core/src/object/file_identifier/shallow.rs @@ -114,6 +114,7 @@ pub async fn shallow( } invalidate_query!(library, "search.paths"); + invalidate_query!(library, "search.objects"); Ok(()) } diff --git a/core/src/object/media/media_processor/shallow.rs b/core/src/object/media/media_processor/shallow.rs index 4312a04d4..19ebc98ef 100644 --- a/core/src/object/media/media_processor/shallow.rs +++ b/core/src/object/media/media_processor/shallow.rs @@ -113,6 +113,7 @@ pub async fn shallow( if run_metadata.media_data.extracted > 0 { invalidate_query!(library, "search.paths"); + invalidate_query!(library, "search.objects"); } Ok(())