Thanks to visit codestin.com
Credit goes to github.com

Skip to content

fix(cli): generate correctly named file in DumpHandler #12409

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Mar 4, 2024

Conversation

mafredri
Copy link
Member

@mafredri mafredri commented Mar 4, 2024

Noticed we always write the filenames with "agent" in the name, this fixes that.

EDIT: As a bonus we did s/:/-/ on time so that files are safe on any filesystem, e.g. NTFS.
EDIT2: As a bonus2 we use time.Now().UTC() since our formatting string appends Z to the filename, but we were actually rendering the local time.

@mafredri mafredri changed the title fix(cli): produce corrently named file in DumpHandler fix(cli): generate corrently named file in DumpHandler Mar 4, 2024
@mafredri mafredri changed the title fix(cli): generate corrently named file in DumpHandler fix(cli): generate correctly named file in DumpHandler Mar 4, 2024
cli/root.go Outdated
@@ -992,7 +992,7 @@ func DumpHandler(ctx context.Context) {
if err != nil {
dir = os.TempDir()
}
fpath := filepath.Join(dir, fmt.Sprintf("coder-agent-%s.dump", time.Now().Format("2006-01-02T15:04:05.000Z")))
fpath := filepath.Join(dir, fmt.Sprintf("coder-%s-%s.dump", name, time.Now().Format("2006-01-02T15:04:05.000Z")))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

out of scope: we should probably not use colons in the file path as that's a forbidden character in NTFS.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, it's such a small change I could piggy back it on this one.

@mafredri mafredri merged commit 4ce1448 into main Mar 4, 2024
@mafredri mafredri deleted the mafredri/fix-dump-filename branch March 4, 2024 16:35
@github-actions github-actions bot locked and limited conversation to collaborators Mar 4, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants