Skip to content

feat: delete stale generated files listed by an output manifest - #37

Merged
omer-cengel merged 2 commits into
masterfrom
feature/generated-output-manifest-cleanup
Sep 25, 2026
Merged

omer-cengel merged 2 commits into
masterfrom
feature/generated-output-manifest-cleanup

Conversation

@omer-cengel

Copy link
Copy Markdown
Member

Summary

A renamed or removed query group, or a changed java.package, used to leave the previous repository behind in java.out, where it kept compiling. A successful sqlcj generate now records its output in sqlcj-manifest.txt inside java.out. The next successful run deletes only the files that manifest listed and it no longer generates, so stale repositories go away while user files stay.

Changes

  • Add GeneratedOutputManifest. It reads the previous manifest, deletes stale files, and writes a UTF-8 manifest with one sorted, /-separated path relative to java.out per line, each line ending in \n.
  • SqlcjCompiler reads the previous manifest after generation and before the first write. It deletes stale files after every generated file is written, and writes the new manifest last, so a failed write or cleanup keeps the previous manifest for the next run.
  • Only a listed regular file inside java.out is deleted. Entries that are absolute, escape the directory, are not normalized, or are empty are skipped, as are directories and any file that is the same file as one this run wrote.
  • New diagnostics Cannot read output manifest: <file>, Cannot delete stale generated file: <file> and Cannot write output manifest: <file> end the run with exit status 1.
  • Tests cover renamed and removed groups, a changed package, retention of unlisted and pre-manifest files, byte-identical repeated output, an unreadable manifest, and a failed compilation that leaves both files and manifest unchanged.
  • The configuration guide, README and quickstart describe the manifest, the cleanup limits and the new diagnostics.

Scope and non-goals

  • Directories, including emptied package directories, are never deleted.
  • A file no previous manifest listed is never deleted, and a missing manifest deletes nothing.
  • Changing java.out leaves the previous output directory untouched.
  • Writing is still not transactional; there is no rollback or staging directory.
  • No generate --check mode and no change to configuration or generated code.

@omer-cengel
omer-cengel merged commit 3a574a2 into master Sep 25, 2026
6 checks passed
@omer-cengel
omer-cengel deleted the feature/generated-output-manifest-cleanup branch September 25, 2026 20:50
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