Skip to content
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

Add support for 'WithModificationTIme()' option #41

Open
anatol opened this issue May 17, 2023 · 1 comment
Open

Add support for 'WithModificationTIme()' option #41

anatol opened this issue May 17, 2023 · 1 comment
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@anatol
Copy link

anatol commented May 17, 2023

In some situations I need to set modification time for the new file.

Having an Option WithPermissions

func WithModificationTime(time time.Time) Option {
	return optionFunc(func(cfg *config) {
		cfg.modTime = &time
	})
}

that takes provided time into account and updates the resulting file would make it possible.

@stapelberg
Copy link
Collaborator

I was about to say “can’t you os.Chtimes() before calling CloseAtomicallyReplace()?”, but I think the problem might be that the t.Sync() and/or t.Close() that CloseAtomicallyReplace calls change the modification time themselves, so the Chtimes needs to happen just above

if err := os.Rename(t.Name(), t.path); err != nil {

Sounds reasonable, pull requests welcome. We probably need to make both atime and mtime configurable in a single option as that’s what os.Chtimes() wants.

@stapelberg stapelberg added enhancement New feature or request help wanted Extra attention is needed labels May 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants