Skip to content

sync: ingest local sources when there are no remote ones - #31

Open
kaihirota wants to merge 1 commit into
prime-radiant-inc:mainfrom
kaihirota:sync-local-sources
Open

kaihirota wants to merge 1 commit into
prime-radiant-inc:mainfrom
kaihirota:sync-local-sources

Conversation

@kaihirota

Copy link
Copy Markdown

What happens today

In SyncManager.runSync() the scan, the ingest and the stats all sit inside
if (remoteSources.length > 0):

if (remoteSources.length > 0) {
  const syncResult = await syncAllRemoteSources(...);
  const sources = this.config.sources.map(expandPath);
  sources.push(...syncResult.cachedPaths);
  const files = scanSources(sources, this.config.exclude);
  const ingestResult = ingestSessions(files, this.db, false);
  ...
}

So a machine with no remote sources configured runs the auto-sync timer on every interval and
ingests nothing. defaultConfig() has remote_sources: [], so that is the default: serve
appears to be keeping the database current and is not.

What this changes

sources is lifted out of the branch, and the scan, ingest and stats run after it. Remote
paths are still appended when there are remotes.

Two tests cover it: local sources are ingested with no remotes configured, and
lastIngestStats reports what was done.

Also

src/web/server.test.ts writes to the user's real config path, and its teardown only
restored a config that had existed beforehand. With no previous config the fixture was left
in place and became the live one. It is now removed in that case.

bun run check passes: 94 tests, typecheck clean.

The scan, the ingest and the stats all sat inside `if (remoteSources.length > 0)`, so a
machine with none configured ran the auto-sync timer every interval and did nothing. The
default config has none, so that is the default.

Also: the server tests write to the user's real config path, and the teardown only restored a
config that had existed before. With no previous config the fixture was left behind and
became the live one.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XewuV2izBAhDPD2gEsGbKf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant