Skip to content

Commit d76c3a5

Browse files
committed
close con on exit
1 parent 5a98e62 commit d76c3a5

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

R/fread.R

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ reopen_connection.url = function(con, ...) {
2424
url(summary(con)$description, "rb")
2525
}
2626

27+
reopen_connection.unz = function(con, ...) {
28+
unz(summary(con)$description, "rb")
29+
}
30+
2731
reopen_connection.pipe = function(con, ...) {
2832
pipe(summary(con)$description, "rb")
2933
}
@@ -148,6 +152,7 @@ yaml=FALSE, tmpdir=tempdir(), tz="UTC")
148152
open(input, "rb")
149153
close_con = input
150154
}
155+
if (!is.null(close_con)) on.exit(close(close_con), add=TRUE)
151156
tmpFile = tempfile(tmpdir=tmpdir)
152157
on.exit(unlink(tmpFile), add=TRUE)
153158
bytes_copied = .Call(CspillConnectionToFile, input, tmpFile, as.numeric(nrows))
@@ -165,7 +170,6 @@ yaml=FALSE, tmpdir=tempdir(), tz="UTC")
165170
connection_spill_info = c(spill_elapsed, bytes_copied)
166171
input = tmpFile
167172
file = tmpFile
168-
if (!is.null(close_con)) close(close_con)
169173
}
170174
if (!is.null(file)) {
171175
if (!is.character(file) || length(file)!=1L)

0 commit comments

Comments
 (0)