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

Investigate the warning emitted by test_export_list.R:19:9 #438

Closed
chainsawriot opened this issue Jul 10, 2024 · 4 comments
Closed

Investigate the warning emitted by test_export_list.R:19:9 #438

chainsawriot opened this issue Jul 10, 2024 · 4 comments

Comments

@chainsawriot
Copy link
Collaborator

Which also got emitted on CI. And actually, the expected file is not created.

@chainsawriot
Copy link
Collaborator Author

This works with the current CRAN version 1.1.1

withr::with_tempdir({
    mylist <- list(
        mtcars3 = mtcars[1:10, ],
        mtcars2 = mtcars[11:20, ],
        mtcars1 = mtcars[21:32, ]
    )
    rio::export_list(mylist, file = paste0("file_", 1:3, ".csv"), archive = "arch/archive.zip")
    file.exists("arch/archive.zip")
})

But not with HEAD

@chainsawriot
Copy link
Collaborator Author

By adding back these two lines to HEAD, this test works.

1f2cfe8

@chainsawriot
Copy link
Collaborator Author

chainsawriot commented Jul 10, 2024

#434 (comment)

As it turns out, that setwd() call is important for exporting compressed file to a relative path, e.g. arch/archive.zip and we can't do that on.exit. b/c that copy operation depends on where the current working directory is.

rio/R/compression.R

Lines 50 to 67 in b79130e

setwd(tmp)
if (type == "zip") {
o <- utils::zip(cfile2, files = basename(filename))
}
if (type == "tar") {
o <- utils::tar(cfile2, files = basename(filename), compression = "none")
}
if (type == "tar.gz") {
o <- utils::tar(cfile2, files = basename(filename), compression = "gzip")
}
if (type == "tar.bz2") {
o <- utils::tar(cfile2, files = basename(filename), compression = "bzip2")
}
setwd(wd)
if (o != 0) {
stop(sprintf("File compression failed for %s!", cfile))
}
file.copy(from = file.path(tmp, cfile2), to = cfile, overwrite = TRUE)

Is there a better way to handle this? And #319 is still a hanging problem.

@chainsawriot
Copy link
Collaborator Author

Until a better solution is derived for #319 , I will add back that setwd(). Please continue the discussion about possible solution in #319.

chainsawriot added a commit that referenced this issue Jul 11, 2024
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

No branches or pull requests

1 participant