Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/development' into development
Browse files Browse the repository at this point in the history
  • Loading branch information
tati-micheletti committed Dec 13, 2018
2 parents 2e4138f + 929b70e commit 74c1a69
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
5 changes: 3 additions & 2 deletions R/postProcess.R
Original file line number Diff line number Diff line change
Expand Up @@ -976,8 +976,9 @@ assessDataType <- function(ras, type = 'writeRaster') {
#' @rdname assessDataType
assessDataType.Raster <- function(ras, type = "writeRaster") {
## using ras@data@... is faster, but won't work for @values in large rasters
if (ncell(ras) > 100000) {
rasVals <- raster::sampleRandom(x = ras, size = 100000)
N <- 1e5
if (ncell(ras) > N) {
rasVals <- suppressWarnings(raster::sampleRandom(x = ras, size = N))
} else {
rasVals <- raster::getValues(ras)
}
Expand Down
16 changes: 9 additions & 7 deletions R/preProcess.R
Original file line number Diff line number Diff line change
Expand Up @@ -732,13 +732,15 @@ linkOrCopy <- function (from, to, symlink = TRUE) {

# Try hard link first -- the only type that R deeply recognizes
warns <- capture_warnings(result <- file.link(from[!dups], to))
toCollapsed <- paste(to, collapse = ", ")
fromCollapsed <- paste(from, collapse = ", ")
if (isTRUE(all(result))) {
message("Hardlinked version of file created at: ", to, ", which points to "
, from, "; no copy was made.")
message("Hardlinked version of file created at: ", toCollapsed, ", which points to "
, fromCollapsed, "; no copy was made.")
}

if (any(grepl("file already exists", warns))) {
message("File named ", paste(to, collapse = ", "), " already exists; will try to use it/them")
message("File named ", toCollapsed, " already exists; will try to use it/them")
result <- TRUE
}

Expand All @@ -747,18 +749,18 @@ linkOrCopy <- function (from, to, symlink = TRUE) {
if (!identical(.Platform$OS.type, "windows")) {
result <- suppressWarnings(file.symlink(from, to))
if (isTRUE(all(result))) {
message("Symlinked version of file created at: ", to, ", which points to "
, from, "; no copy was made.")
message("Symlinked version of file created at: ", toCollapsed, ", which points to "
, fromCollapsed, "; no copy was made.")
}
}
}

if (isFALSE(all(result))) {
result <- file.copy(from, to)
message("Copy of file: ", from, ", was created at: ", to)
message("Copy of file: ", fromCollapsed, ", was created at: ", toCollapsed)
}
} else {
message("File ", from, " does not exist. Not copying.")
message("File ", fromCollapsed, " does not exist. Not copying.")
result <- FALSE
}
return(result)
Expand Down

0 comments on commit 74c1a69

Please sign in to comment.