Verify (and optionally write) checksums. Checksums are computed using .digest, which is simply a wrapper around digest::digest.

Checksums(path, write, quickCheck = FALSE, checksumFile = file.path(path,
  "CHECKSUMS.txt"), files = NULL, ...)

# S4 method for character,logical
Checksums(path, write, quickCheck = FALSE,
  checksumFile = file.path(path, "CHECKSUMS.txt"), files = NULL, ...)

# S4 method for character,missing
Checksums(path, write, quickCheck = FALSE,
  checksumFile = file.path(path, "CHECKSUMS.txt"), files = NULL, ...)

Arguments

path

Character string giving the path to the module directory.

write

Logical indicating whether to overwrite CHECKSUMS.txt. Default is FALSE, as users should not change this file. Module developers should write this file prior to distributing their module code, and update accordingly when the data change.

quickCheck

Logical. If TRUE, then this will only use file sizes, rather than a digest::digest hash. This is generally faster, but will be much less robust.

checksumFile

The filename of the checksums file to read or write to. The default is CHECKSUMS.txt located at file.path(path, module, "data", checksumFile). It is likely not a good idea to change this, and should only be used in cases such as Cache, which can evaluate if the checksumFile has changed.

files

An optional character string or vector of specific files to checksum. This may be very important if there are many files listed in a CHECKSUMS.txt file, but only a few are to be checksummed.

...

Passed to digest and write.table. For digest, the notable argument is algo. For write.table, the notable argument is append.

Value

A data.table with columns: result, expectedFile, actualFile, checksum.x, checksum.y, algorithm.x, algorithm.y, filesize.x, filesize.y indicating the result of comparison between local file (x) and expectation based on the CHECKSUMS.txt file.

Note

In version 1.2.0 and earlier, two checksums per file were required because of differences in the checksum hash values on Windows and Unix-like platforms. Recent versions use a different (faster) algorithm and only require one checksum value per file. To update your CHECKSUMS.txt files using the new algorithm, see https://github.com/PredictiveEcology/SpaDES/issues/295#issuecomment-246513405.

Examples

# NOT RUN {
moduleName <- "my_module"
modulePath <- file.path("path", "to", "modules")

## verify checksums of all data files
Checksums(moduleName, modulePath)

## write new CHECKSUMS.txt file

# 1. verify that all data files are present (and no extra files are present)
list.files(file.path(modulePath, moduleName, "data"))

# 2. calculate file checksums and write to file (this will overwrite CHECKSUMS.txt)
Checksums(moduleName, modulePath, write = TRUE)
# }