Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Download caching function? #40

Open
koheiw opened this issue May 8, 2018 · 2 comments
Open

Download caching function? #40

koheiw opened this issue May 8, 2018 · 2 comments

Comments

@koheiw
Copy link

koheiw commented May 8, 2018

I had download() function in the readtext package, whose primary function is to save downloaded files locally as cache files to avoid downloading of the same files.

However, I decided to move that function to somewhere else because the function is not specifically about textual data. The new home for the function can be a new single function package downloadCache, but, before start making the package, I want to know if you have a plan to add a similar function to simpleCache.

I am also happy to issue a PR if you think that function fits well to your package.

@nsheff
Copy link
Member

nsheff commented May 8, 2018

There actually was once such a function in simpleCache:

cff1743

I removed it because I never had it 100% working and I didn't want to have non-working cruft in the release package when we submitted to CRAN.

So, I would welcome a PR with a fully functional version of that function. I have a few thoughts first about how it would work:

  • the function should go through the simpleCache function for the actual caching part so we don't duplicate code.
  • would it be better to just modify the simpleCache function so that it can take either an instruction (like it does now) or a url (which it would download)?
  • how do you deal with different file types in the given URL? In my original version I was just using read.table to read in that file, but that only works for table-like files. in theory the url could be anything right? so would you pipe that through your readtext function? in that case, we could add readtext to the enhances section of simpleCache, and then throw an error if it is not installed and the user uses the url argument?

@koheiw
Copy link
Author

koheiw commented May 9, 2018

Hi @nsheff interesting to hear about the history of the package. I was thinking to use simpleCache as underlying caching function, and define a special behavior for a URL to that function makes sense. As for the file types, I had the same problem in readtext, but made the function to return path to cached file instead of file content so that appropriate IO function can be used. If it does not sound good, we could limit the supported file types to either RDS or RDA.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants