-
Notifications
You must be signed in to change notification settings - Fork 124
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
Add a way to configure destination directory #68
base: master
Are you sure you want to change the base?
Conversation
@froger Can you put these methods part of the |
@wcandillon yes sure, when I started I though "it could have more options". But when finished writing, my thoughts were "all this code just to rewrite BASE_URL". I will find something more straight forward and write some unit-tests as well. But I don't know if this feature is somewhat useful in the scope of the lib. The no-brainer&no-config of the lib is quiet pleasant, so at this end maybe this feature have no places in your lib. |
@wcandillon I've updated my pull request, and did some tests on a project of mine. What I've done
What's next Basically, introducing a
These updates worked good for my project, but again, maybe this lib doesn't need them. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. Made two minor comments. I will integrate your branch in my own projects in order to do a bit more testing.
src/CacheManager.js
Outdated
@@ -3,7 +3,12 @@ import * as _ from "lodash"; | |||
import {FileSystem} from "expo"; | |||
import SHA1 from "crypto-js/sha1"; | |||
|
|||
const BASE_DIR = `${FileSystem.cacheDirectory}expo-image-cache/`; | |||
let _baseDir = `${FileSystem.cacheDirectory}expo-image-cache/`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For simplicity, would it be possible to add this method to CacheManager for simplicity?
* As we can now set an uri that is not in the cacheDirectory, | ||
* we need to be able to delete files. | ||
*/ | ||
export const removeCacheEntry = async (uri: string): Promise => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should return
be await
and Promise be Promise<void>
?
…o-image-cache into cache-config
@froger Could you rebase against the latest version? |
I have a use case where I need to cache permanently the images.
The application we are on will be used most of the time offline, and should not ever destroy image caches.
I just added in this pull request the ability to edit the
BASE_URL
configuration outside the lib.