From b814133e13a553d04435ef222021c268747271ec Mon Sep 17 00:00:00 2001 From: Hamish Peebles Date: Tue, 23 Jan 2024 15:20:03 +0000 Subject: [PATCH] Use `take` rather than `get` --- .../impl/src/jobs/sync_events_to_user_canisters.rs | 2 +- .../impl/src/jobs/sync_events_to_user_index_canister.rs | 2 +- .../canisters/user/impl/src/jobs/push_user_canister_events.rs | 2 +- .../impl/src/jobs/sync_events_to_local_user_index_canisters.rs | 2 +- .../user_index/impl/src/jobs/sync_users_to_storage_index.rs | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/backend/canisters/local_user_index/impl/src/jobs/sync_events_to_user_canisters.rs b/backend/canisters/local_user_index/impl/src/jobs/sync_events_to_user_canisters.rs index 782b8114e3..4c8b416640 100644 --- a/backend/canisters/local_user_index/impl/src/jobs/sync_events_to_user_canisters.rs +++ b/backend/canisters/local_user_index/impl/src/jobs/sync_events_to_user_canisters.rs @@ -22,7 +22,7 @@ pub(crate) fn start_job_if_required(state: &RuntimeState) -> bool { pub(crate) fn try_run_now(state: &mut RuntimeState) -> bool { if let Some(batch) = next_batch(state) { - if let Some(timer_id) = TIMER_ID.get() { + if let Some(timer_id) = TIMER_ID.take() { ic_cdk_timers::clear_timer(timer_id); } ic_cdk::spawn(process_batch(batch)); diff --git a/backend/canisters/local_user_index/impl/src/jobs/sync_events_to_user_index_canister.rs b/backend/canisters/local_user_index/impl/src/jobs/sync_events_to_user_index_canister.rs index 9da7671c37..d758c15152 100644 --- a/backend/canisters/local_user_index/impl/src/jobs/sync_events_to_user_index_canister.rs +++ b/backend/canisters/local_user_index/impl/src/jobs/sync_events_to_user_index_canister.rs @@ -22,7 +22,7 @@ pub(crate) fn start_job_if_required(state: &RuntimeState) -> bool { pub(crate) fn try_run_now(state: &mut RuntimeState) -> bool { if let Some((canister_id, events)) = next_batch(state) { - if let Some(timer_id) = TIMER_ID.get() { + if let Some(timer_id) = TIMER_ID.take() { ic_cdk_timers::clear_timer(timer_id); } ic_cdk::spawn(sync_events(canister_id, events)); diff --git a/backend/canisters/user/impl/src/jobs/push_user_canister_events.rs b/backend/canisters/user/impl/src/jobs/push_user_canister_events.rs index fad06b65be..17f70c61c5 100644 --- a/backend/canisters/user/impl/src/jobs/push_user_canister_events.rs +++ b/backend/canisters/user/impl/src/jobs/push_user_canister_events.rs @@ -22,7 +22,7 @@ pub(crate) fn start_job_if_required(state: &RuntimeState) -> bool { pub(crate) fn try_run_now_for_canister(state: &mut RuntimeState, canister_id: CanisterId) -> bool { if let Some(events) = state.data.user_canister_events_queue.try_start_for_canister(canister_id) { - if let Some(timer_id) = TIMER_ID.get() { + if let Some(timer_id) = TIMER_ID.take() { ic_cdk_timers::clear_timer(timer_id); } ic_cdk::spawn(process_batch(vec![(canister_id, events)])); diff --git a/backend/canisters/user_index/impl/src/jobs/sync_events_to_local_user_index_canisters.rs b/backend/canisters/user_index/impl/src/jobs/sync_events_to_local_user_index_canisters.rs index 92a79310e7..0d5ff036d7 100644 --- a/backend/canisters/user_index/impl/src/jobs/sync_events_to_local_user_index_canisters.rs +++ b/backend/canisters/user_index/impl/src/jobs/sync_events_to_local_user_index_canisters.rs @@ -22,7 +22,7 @@ pub(crate) fn start_job_if_required(state: &RuntimeState) -> bool { pub(crate) fn try_run_now(state: &mut RuntimeState) -> bool { if let Some(batch) = next_batch(state) { - if let Some(timer_id) = TIMER_ID.get() { + if let Some(timer_id) = TIMER_ID.take() { ic_cdk_timers::clear_timer(timer_id); } ic_cdk::spawn(process_batch(batch)); diff --git a/backend/canisters/user_index/impl/src/jobs/sync_users_to_storage_index.rs b/backend/canisters/user_index/impl/src/jobs/sync_users_to_storage_index.rs index 09410a19e6..dc4876229b 100644 --- a/backend/canisters/user_index/impl/src/jobs/sync_users_to_storage_index.rs +++ b/backend/canisters/user_index/impl/src/jobs/sync_users_to_storage_index.rs @@ -22,7 +22,7 @@ pub(crate) fn start_job_if_required(state: &RuntimeState) -> bool { pub(crate) fn try_run_now(state: &mut RuntimeState) -> bool { if let Some((canister_id, users)) = next_batch(state) { - if let Some(timer_id) = TIMER_ID.get() { + if let Some(timer_id) = TIMER_ID.take() { ic_cdk_timers::clear_timer(timer_id); } ic_cdk::spawn(sync_users(canister_id, users));