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