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

fix: For Windows, close temp file before removing #22492

Merged
merged 3 commits into from
Sep 16, 2021

Conversation

davidby-influx
Copy link
Contributor

Close temp files before removing them, because
Windows does not permit open files to be removed.

Closes #21470

@@ -218,7 +218,7 @@ func (cmd *Command) parseFlags(args []string) (err error) {
return err
}

func (cmd *Command) backupShard(db, rp, sid string) error {
func (cmd *Command) backupShard(db, rp, sid string) (err error) {
Copy link
Contributor

@lesam lesam Sep 16, 2021

Choose a reason for hiding this comment

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

could we call this returnErr or rErr or something? That seems cleaner than renaming the other errors later and avoids the risk of potential shadowing in the future.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That was my first fix (see initial commit), calling it simply e. But I decided that preserving the convention of the return be called err was cleaner. More code changes now, but more understandable code in a year.

Copy link
Contributor

@lesam lesam Sep 16, 2021

Choose a reason for hiding this comment

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

I find returnErr = err much more understandable (now and in a year) because I can easily see I'm intending to change the return value and I can easily see that it is never shadowed (since I only assign to it in defer statements). I don't find that a naming convention for named error returns has much value, and I'd prefer if our convention was to specifically not name them err - i.e. func(myval Value) (err error) should be considered harmful, func(myval Value) error or func(myval Value) (returnErr error) or func(myval Value) (ret1 ReturnType1, _ error) is better in my opinion.

That said, not worth blocking the PR on.

@davidby-influx davidby-influx merged commit d2199ef into master-1.x Sep 16, 2021
@davidby-influx davidby-influx deleted the DSB_windows_backup branch September 16, 2021 16:52
davidby-influx added a commit that referenced this pull request Oct 14, 2021
davidby-influx added a commit that referenced this pull request Oct 14, 2021
chengshiwen pushed a commit to chengshiwen/influxdb that referenced this pull request Aug 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

influxd (1.x) backup -portable does not delete uncompress shard archives on Windows
2 participants