Closed gdelaplante closed 2 years ago
Yeah I can see the issue. I think a good fix would be to simply ensure that the directory is empty before downloading and then spit out a good error message that you need to move or delete the existing file.
Prior to this we always simply overwrote the previous HYDAT. I think this is still right and that we don't want to preserve old versions of HYDAT on someone's computer but I was to raise that here as well.
To unblock you can of course simply empty the directory in hy_dir()
and then run download_hydat()
again.
Working with a dated local version of hydat and version 0.5.6 of tidyhydat downloaded from CRAN OR from GitHub:
Downloading works if starting with an empty download directory (...Local/tidyhydat/tidyhydat) but fails again once Hydat.sqlite3 is created again:
After failure, two files appear in the download directory where there should be one:
The issue evidently stems from lines 112:116 of download.R:
'from' is of length 2 (owing to the two files with .sqlite3 extension) while 'to' is of length one. This stems from the line above,
utils::unzip(tmp, exdir = dl_hydat_here, overwrite = TRUE))
, which creates a second file (the new database).If I get time I'll fix the issue and submit a pull request in the next day or two!