Pomax / node-flickrapi

A node.js (and client-library) implementation of the Flickr API with oauth API key authentication and API method proxying
177 stars 51 forks source link

Moved cache 'data' dir to within the node module (currently project root) #83

Closed benlowry closed 8 years ago

benlowry commented 8 years ago

If it's writing into /data for a reason I can do a pull request to make it configurable if that's better?

Pomax commented 8 years ago

Heya, thanks for filing a PR, but the data dir (or any dir with user data generated over the course of an app's lifetime) should not be placed inside node_modules. As user data, it should liver either in your project root, or if you want it somewhere else you need to override its location using the options object.

If you want to update the PR so that instead of hardcoding __dirname, the location is kept the same unless there is an options.datapath override (with README.md update to make that clear)

The reason is that the node_modules directory is entirely unsafe when it comes to data preservation: any system is allowed to wipe it and then rebuild off of the package.json dependency list, so transient data should never be kept in node_modules. The only requirement is that the dependencies are preserved, any other data is fair game to wipe. This becomes especially pertinent for deployment systems, where a node_modules dir may be rebuilt every X hours or days for security purposes, or simply cloned from a known local cache, possibly even outside your control.