ropensci / tidyhydat

An R package to import Water Survey of Canada hydrometric data and make it tidy
https://docs.ropensci.org/tidyhydat
Apache License 2.0
70 stars 19 forks source link

Issue with download_hydat() during extraction #192

Open SteveCoss opened 1 year ago

SteveCoss commented 1 year ago

After a successful download, Hydat is no longer extracting correctly on linux server.

image

Additional context was functioning fine, then I was having issues so I updated versions of tidyhydat (running the github version now) and get this error on update. I've tried: fp=hy_dir() ffp=paste(fp,"/*",sep = "") unlink(ffp, recursive = T, force = T) print("hydat version older than today's date. Downloading hydat.") download_hydat(dl_hydat_here = NULL, ask = FALSE)

Which I was using previously if hydat wouldn't download. I suspect this issue is related to recent server updates on my end, but I'm hoping there's a workaround that skips the temporary directory.

boshek commented 1 year ago

Hi there. Thanks for reporting this. A couple things. I have a Linux server that I have access too and using the most recent version of tidyhydat, I was not able to reproduce this.

So a couple options. You could try downloading hydat to a different location via the dl_hydat_here argument. Then you could set that path in every function you call. So for example:

library(tidyhydat)
download_hydat(dl_hydat_here = "my/cool/path")

hy_daily_flows("08MF005", hydat_path = "my/cool/path")

Really we should have set that so that you can use an environment variable. If you ever felt like making a PR adding the ability to set the download location via environment variable would be really good.

The other option is to just manually download it from ECCC and then move it to the location of hy_dir()

SteveCoss commented 1 year ago

Hey Sam, I think what's happening is that my server permissions are forcing it to go to that temp folder no mater what path argument I pass. Moving the file is a great workaround until I can sort that out sit the admin folks. Thanks for your help.

boshek commented 1 year ago

Weird. Anything info you can provide is much appreciated because I'd love to sort this out for users. If you step through the download_hydat() function, can you see exactly where that forcing is happening?