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

Overwrite files if they exist #84

Merged
merged 3 commits into from
Oct 19, 2018
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion R/build.R
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ build_package <- function(path, tmpdir, build_args, libpath, quiet) {
)

} else {
file.copy(path, tmpdir)
file.copy(path, tmpdir, overwrite = TRUE)
file.path(tmpdir, basename(path))
}
}
6 changes: 6 additions & 0 deletions R/package.R
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,12 @@ do_check <- function(targz, package, args, libpath, repos,
profile <- make_fake_profile(session_output = session_output)
on.exit(unlink(profile), add = TRUE)

# if the pkg.Rcheck directory already exists, unlink it
check_dir <- paste0(package, ".Rcheck")
if (file.exists(check_dir)) {
Copy link
Member

Choose a reason for hiding this comment

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

I think we don't need to check for this, just unlink, it will do nothing if it does not exist, anyway. IMO checking for the existence of a file, is almost always an anti-pattern.

Copy link
Member Author

Choose a reason for hiding this comment

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

Sure that is fair, race conditions.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, it might even make sense to filelock::filelock() the check dir, in case you call multiple checks from multiple sessions, and unlock() in on.exit. But we don't have to do that in this PR.

unlink(check_dir, recursive = TRUE)
}

if (!quiet) cat_head("R CMD check")
res <- with_envvar(
c(R_PROFILE_USER = profile,
Expand Down
3 changes: 3 additions & 0 deletions inst/NEWS.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@

# devel

* `rcmdcheck()` now correctly overwrites existing tarballs if they already
exist in the check directory (#84 @jimhester).
Copy link
Member

Choose a reason for hiding this comment

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

This is not just the tarballs, right? But overwrites (well, replaces) the whole check directory, right?

Copy link
Member Author

Choose a reason for hiding this comment

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

No it is just the tarballs, if it is a directory it uses the other part of the conditional that is unchanged.

Copy link
Member

Choose a reason for hiding this comment

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

Oh, OK, got it.


# 1.3.0

* New `rcmdcheck_process` class to run `R CMD check` in the background.
Expand Down