refactor: apply clippy
This commit is contained in:
@@ -693,7 +693,10 @@ impl StorageUsagePort for StorageUsageService {
|
||||
})?;
|
||||
|
||||
let corrected = result.rows_affected();
|
||||
info!("Storage-usage reconciliation corrected {} user(s)", corrected);
|
||||
info!(
|
||||
"Storage-usage reconciliation corrected {} user(s)",
|
||||
corrected
|
||||
);
|
||||
Ok(corrected)
|
||||
}
|
||||
|
||||
|
||||
+10
-6
@@ -1141,9 +1141,8 @@ impl AppServiceFactory {
|
||||
// Registered with the periodic-job scheduler
|
||||
// (`docs/plan/job-registry.md` Part 1); the retired
|
||||
// `start_reconciliation_job` used to spawn its own interval loop.
|
||||
let interval = StorageUsageService::reconciliation_interval(
|
||||
self.config.storage.usage_reconcile_secs,
|
||||
);
|
||||
let interval =
|
||||
StorageUsageService::reconciliation_interval(self.config.storage.usage_reconcile_secs);
|
||||
if let Err(e) = core
|
||||
.job_registry
|
||||
.register(service.clone(), Some(interval), None)
|
||||
@@ -1286,8 +1285,7 @@ impl AppServiceFactory {
|
||||
if let Err(e) = core
|
||||
.job_registry
|
||||
.register(
|
||||
core.dedup_service.clone()
|
||||
as Arc<dyn crate::infrastructure::scheduler::JobHandler>,
|
||||
core.dedup_service.clone() as Arc<dyn crate::infrastructure::scheduler::JobHandler>,
|
||||
None, // on-demand only
|
||||
None, // no timeout
|
||||
)
|
||||
@@ -1357,7 +1355,13 @@ impl AppServiceFactory {
|
||||
// path inside the application services, and re-exposed on AppState
|
||||
// for the handler-side quota checks of the byte-upload paths).
|
||||
let storage_usage = self
|
||||
.create_storage_usage_service(&repos, &pool, &maintenance_pool, drive_repo.clone(), &core)
|
||||
.create_storage_usage_service(
|
||||
&repos,
|
||||
&pool,
|
||||
&maintenance_pool,
|
||||
drive_repo.clone(),
|
||||
&core,
|
||||
)
|
||||
.await;
|
||||
|
||||
// 3d. Content index (embedded Tantivy) — opened before application
|
||||
|
||||
@@ -144,10 +144,7 @@ pub(super) async fn dispatch(name: &str, entry: Arc<JobEntry>) -> JobOutcome {
|
||||
name,
|
||||
);
|
||||
advance_next_run(&entry);
|
||||
return JobOutcome::ok_with(
|
||||
0,
|
||||
serde_json::json!({ "skipped": "already_running" }),
|
||||
);
|
||||
return JobOutcome::ok_with(0, serde_json::json!({ "skipped": "already_running" }));
|
||||
}
|
||||
};
|
||||
|
||||
@@ -196,8 +193,7 @@ pub(super) async fn dispatch(name: &str, entry: Arc<JobEntry>) -> JobOutcome {
|
||||
// by one interval, no backlog queueing.
|
||||
state.next_run_at = entry.interval.map(|dur| {
|
||||
Utc::now()
|
||||
+ chrono::Duration::from_std(dur)
|
||||
.unwrap_or_else(|_| chrono::Duration::seconds(0))
|
||||
+ chrono::Duration::from_std(dur).unwrap_or_else(|_| chrono::Duration::seconds(0))
|
||||
});
|
||||
}
|
||||
|
||||
@@ -217,8 +213,7 @@ fn advance_next_run(entry: &JobEntry) {
|
||||
let mut state = entry.state.lock().expect("JobState mutex poisoned");
|
||||
state.next_run_at = entry.interval.map(|dur| {
|
||||
Utc::now()
|
||||
+ chrono::Duration::from_std(dur)
|
||||
.unwrap_or_else(|_| chrono::Duration::seconds(0))
|
||||
+ chrono::Duration::from_std(dur).unwrap_or_else(|_| chrono::Duration::seconds(0))
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -95,8 +95,7 @@ impl JobRegistry {
|
||||
}
|
||||
let next_run_at = interval.map(|dur| {
|
||||
Utc::now()
|
||||
+ chrono::Duration::from_std(dur)
|
||||
.unwrap_or_else(|_| chrono::Duration::seconds(0))
|
||||
+ chrono::Duration::from_std(dur).unwrap_or_else(|_| chrono::Duration::seconds(0))
|
||||
});
|
||||
let entry = Arc::new(JobEntry {
|
||||
handler,
|
||||
@@ -186,10 +185,7 @@ impl JobRegistry {
|
||||
///
|
||||
/// Works for BOTH scheduled and on-demand jobs — for on-demand
|
||||
/// jobs this is the only way they ever run.
|
||||
pub async fn trigger(
|
||||
self: &Arc<Self>,
|
||||
name: &str,
|
||||
) -> Option<JobOutcome> {
|
||||
pub async fn trigger(self: &Arc<Self>, name: &str) -> Option<JobOutcome> {
|
||||
let entry = self.get(name).await?;
|
||||
Some(super::engine::dispatch(name, entry).await)
|
||||
}
|
||||
@@ -287,7 +283,9 @@ mod tests {
|
||||
.await
|
||||
.unwrap();
|
||||
// On-demand job — supervisor must never pick it.
|
||||
reg.register(handler("on_demand"), None, None).await.unwrap();
|
||||
reg.register(handler("on_demand"), None, None)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let (next_name, _) = reg.pick_next().await.expect("scheduled job due");
|
||||
assert_eq!(
|
||||
|
||||
@@ -3151,10 +3151,9 @@ impl crate::infrastructure::scheduler::JobHandler for DedupService {
|
||||
async fn run(&self) -> crate::infrastructure::scheduler::JobOutcome {
|
||||
use crate::infrastructure::scheduler::JobOutcome;
|
||||
match self.garbage_collect().await {
|
||||
Ok((items, bytes)) => JobOutcome::ok_with(
|
||||
items,
|
||||
serde_json::json!({ "bytes_reclaimed": bytes }),
|
||||
),
|
||||
Ok((items, bytes)) => {
|
||||
JobOutcome::ok_with(items, serde_json::json!({ "bytes_reclaimed": bytes }))
|
||||
}
|
||||
Err(e) => JobOutcome::Err(format!("dedup GC failed: {e}")),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -122,10 +122,9 @@ impl JobHandler for GrantCleanupService {
|
||||
/// `Arc<GrantCleanupService>` from the handler.
|
||||
async fn run(&self) -> JobOutcome {
|
||||
match self.purge(None).await {
|
||||
Ok(count) => JobOutcome::ok_with(
|
||||
count,
|
||||
serde_json::json!({ "grace_days": self.grace_days }),
|
||||
),
|
||||
Ok(count) => {
|
||||
JobOutcome::ok_with(count, serde_json::json!({ "grace_days": self.grace_days }))
|
||||
}
|
||||
Err(e) => JobOutcome::Err(format!("grant cleanup failed: {e}")),
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user