a previous build's output is copied as assets when building elsewhere #3

closed cmc opened this on 2026-08-30 07:30 UTC

Discussion

cmc 2026-08-30 07:30 UTC

excluded_dirs (src/site.rs:1451) drops the output directory from discovery only when it sits inside the source. Build the same source somewhere else and a previous build's output is just an ordinary directory in the source tree, so every file in it is copied as an asset.

Reproduction, on this repository, following two workflows the docs recommend:

# docs/guide/10-deploying.org: build into the source
orgo build docs -o docs/_site --strict
built 15 page(s), copied 2 asset(s)

# docs/guide/09-auditing.org: preview somewhere else
orgo build docs -o /tmp/preview --no-cache
built 15 page(s), copied 21 asset(s)

/tmp/preview now holds a stale nested copy of the whole site at /tmp/preview/_site/, and is 620K rather than 324K. Nothing warns, and --strict passes.

This is not specific to _site or to a repository that gitignores it. Any earlier output directory left in the source is copied on any build that writes elsewhere; _site is just the name docs/guide/10-deploying.org uses.

The order matters, which is what makes it easy to miss: build to _site first and every later preview carries a copy of it, while a checkout that has never built into the source copies the 2 assets it should.

The guard for the mirror-image case already exists two functions up. collect_assets (src/site.rs:1401) refuses a build.assets root that contains the output directory, with the comment "would copy the site into itself, one build at a time" — the same failure, caught in the configured-asset-root path but not in the source-tree path.

Worth deciding rather than assuming:

  1. Skip a directory in the source that looks like a build output — one holding an .orgo-cache.json. That is precise (the manifest is orgo's own, and discover already knows not to copy it) and needs no configuration, but it is inference.
  2. Add an exclude list to [build]. There is no way to exclude anything today — excluded_dirs returns the templates directory and the nested output, and that is all — so this has uses beyond this bug. It also asks every user to know about it.
  3. Warn rather than skip: say that N assets came from a directory that looks like a built site. Cheapest and it fixes nothing on its own.

Option 1 fixes the reported case with no user action. Option 2 is the general answer and would cover a node_modules or a .venv-shaped problem that nothing handles now either.

closed by commit 141ea8a99b by cmc: Stop copying a previous build's output, and point at the new docs site

2026-08-30 16:21 UTC