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

cleanup putMany implementation #80

Merged
merged 1 commit into from Apr 13, 2020
Merged

cleanup putMany implementation #80

merged 1 commit into from Apr 13, 2020

Conversation

Stebalien
Copy link
Member

  • Use a map for dirsToSync to avoid syncing the same dir multiple times.
  • Keep track of files in a slice, and use offsets into the slice to keep track
    of which ones have been closed/removed.

Also, record the fact that we've created a temporary file before we try to write to it, in case the write fails. That way, we'll try to remove it when we abort.

// signify removed
ops[fi] = 2
} else if !done {
_ = os.Remove(pop.file.Name())
Copy link
Contributor

Choose a reason for hiding this comment

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

I've convinced myself this works, but there are two things suboptimal we might want to make better:

  • The distinction between pop.path and pop.file.Name() is not well named - which is previous vs new location?
  • We're accessing a method (.Name()) after .Close()ing files. That's relying on the internal behavior to not clear all state when closing the handle, which an implementation would be within its rights to do.

* Use a map for dirsToSync to avoid syncing the same dir multiple times.
* Keep track of files in a slice, and use offsets into the slice to keep track
of which ones have been closed/removed.

Also, record the fact that we've created a temporary file _before_ we try to
write to it, in case the write fails. That way, we'll try to remove it when we
abort.
@Stebalien
Copy link
Member Author

@willscott good point. I've addressed your feedback.

@Stebalien Stebalien merged commit bcc4dcb into master Apr 13, 2020
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.

None yet

2 participants