Repository navigation
tui/audit: give every export its own timestamped file - #386
Open
NopeCharon wants to merge 1 commit into
Open
NopeCharon wants to merge 1 commit into
NopeCharon wants to merge 1 commit into
Conversation
doExport wrote both the page export (e) and the all-rows export (E) to the same fixed path, ~/.solongate/audit-export.jsonl, with os.WriteFile. A second export silently replaced the first, and the success note gave no sign that an earlier file had just been destroyed. Exporting one filter's rows and then another's left only the last. Each export now goes to a new file named after the local time it ran, audit-export-20260102-153000.jsonl. createExportFile opens it with O_CREATE|O_EXCL, so two exports in the same second cannot collide either: the second becomes audit-export-20260102-153000-2.jsonl, and so on. The search gives up with an error after 100 names rather than looping on a directory that refuses them all. The success note already names the file it wrote, so it now names the unique one. Because the file is always new and created with mode 0600, the follow-up os.Chmod that tightened the mode of a reused file is no longer needed. If writing or closing the file fails, the partial file is removed before the error is shown. The help overlay now names the pattern, audit-export-*.jsonl. Fixes solongate#358. Signed-off-by: NopeCharon <115794254+NopeCharon@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #358.
In the TUI's Audit panel,
doExportwrote both the page export (e) and the all-rows export (E) to the same fixed path,~/.solongate/audit-export.jsonl, usingos.WriteFile. A second export silently replaced the first, and the success note gave no sign that an earlier file had just been destroyed. Exporting one filter's rows and then another's left only the last.Change
In
packages/tui/audit/audit_keys.go:audit-export-20260102-153000.jsonl.createExportFileopens that file withO_CREATE|O_EXCL, so two exports in the same second cannot collide either. The second one becomesaudit-export-20260102-153000-2.jsonl, and so on. After 100 taken names it returns an error instead of looping on a directory that refuses them all.os.Chmod, which only mattered for a reused file, is gone.In
packages/tui/audit/audit_view.go, the help overlay now names the pattern,audit-export-*.jsonl.The export contents are unchanged. Nothing on the decision path changes.
Tests
In
packages/tui/audit/audit_keys_test.go:audit-export-*.jsonlfile instead of reading the fixed path.TestDoExportKeepsEarlierExports: two exports in a row leave two files, each holding its own rows, and each named by its note. This fails onmain.TestCreateExportFileNeverReusesAName: three files created for the same timestamp get the plain name, then-2, then-3, and none has group or other access.TestCreateExportFileGivesUpWhenEveryNameIsTaken: once every candidate name is taken, the next call returns an error.I ran
go vet ./audit/(also withGOOS=windows) andgo test -count=1 ./audit/inpackages/tuilocally on macOS.packages/tui/livehas the same fixed-name pattern for its own export (live-export.jsonl). I left it out to keep this to the one panel the issue covers.