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 the close in on.exit before opening the connection #1051

Merged
merged 2 commits into from
Dec 6, 2019

Conversation

cderv
Copy link
Contributor

@cderv cderv commented Dec 5, 2019

This fixes #1050 by adding the on.exit(close(con, add = TRUE)) before opening the connection as in other function like write_file

readr/R/file.R

Lines 49 to 58 in 192cb1c

write_file <- function(x, path, append = FALSE) {
path <- standardise_path(path, input = FALSE)
if (!isOpen(path)) {
on.exit(close(path), add = TRUE)
if (isTRUE(append)) {
open(path, "ab")
} else {
open(path, "wb")
}
}

@jimhester
Copy link
Collaborator

Thanks, can you please add a bullet to NEWS? It should briefly describe the change and end with (@yourname, #issuenumber).

@cderv
Copy link
Contributor Author

cderv commented Dec 6, 2019

I was not sure it was considered as a user-facing change. done.

@jimhester jimhester merged commit 4bb6ab2 into tidyverse:master Dec 6, 2019
@jimhester
Copy link
Collaborator

Thanks Christophe!

Thanks a million!

@cderv cderv deleted the close-con branch December 7, 2019 10:53
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.

read_csv does not close unsuccessful connections
2 participants