Skip to contents

Confirms that every file the download planned to save is actually present, and is the size the OSF reported. Called at the end of osf_file_download().

Usage

.osf_verify_downloads(ret, download_to, check_size = TRUE)

Arguments

ret

the return table being built, with path and downloaded columns

download_to

the absolute folder the project was saved in

check_size

whether to compare each file's size on disk against the size the OSF reported. May be a single value, or one value per row: in zip mode with unzip = FALSE, rows covered by an archive share one file on disk (so a per-file size comparison is meaningless for them), while rows fetched individually because no archive could hold them are real files whose size can and should be checked.

Value

ret with downloaded corrected against the file system, and a size_on_disk column added

Details

A row can be marked as downloaded because the copy step ran for it, while nothing usable ended up on disk: the transfer may have failed after retries, file.copy() may have returned FALSE, the file system may have rejected the name, or the write may have been truncated. Only the file system settles it.

Size is compared where the OSF reported one. A file present but a different size is counted as not downloaded, since a truncated file is worse than an absent one – it looks complete to everything downstream.