MCPcopy Create free account
hub / github.com/ScriptedAlchemy/tracedecay / degraded_poll_loop

Function degraded_poll_loop

src/daemon/git_watch.rs:768–794  ·  view source on GitHub ↗

The degraded fallback: mtime-poll HEAD + packed-refs every 5 minutes and sync when they advance. Used when the inotify watcher cannot be built or dies (e.g. ENOSPC). Covers ONE project — never a global failure.

(
    inner: &Arc<GitWatcherInner>,
    state: &Arc<WatchState>,
    common: Option<&Path>,
)

Source from the content-addressed store, hash-verified

766/// sync when they advance. Used when the inotify watcher cannot be built or
767/// dies (e.g. ENOSPC). Covers ONE project — never a global failure.
768async fn degraded_poll_loop(
769 inner: &Arc<GitWatcherInner>,
770 state: &Arc<WatchState>,
771 common: Option<&Path>,
772) {
773 let mut last_sig: Option<(SystemTime, SystemTime)> = None;
774 loop {
775 state.health.beat();
776 if let Some(common) = common {
777 let sig = metadata_signature(common);
778 if sig != last_sig && last_sig.is_some() {
779 let _permit = inner.sync_semaphore.acquire().await;
780 if sync_project(
781 &state.project_root,
782 &TraceDecayOpenOptions::default(),
783 inner.config.full_sync_escalation_files,
784 )
785 .await
786 {
787 state.health.mark_synced();
788 }
789 }
790 last_sig = sig;
791 }
792 tokio::time::sleep(DEGRADED_POLL_INTERVAL).await;
793 }
794}
795
796/// mtime signature of HEAD + packed-refs for the degraded poller.
797fn metadata_signature(common: &Path) -> Option<(SystemTime, SystemTime)> {

Callers 1

project_taskFunction · 0.85

Calls 5

metadata_signatureFunction · 0.85
sync_projectFunction · 0.85
beatMethod · 0.80
mark_syncedMethod · 0.80
acquireMethod · 0.45

Tested by

no test coverage detected