-
Notifications
You must be signed in to change notification settings - Fork 334
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
Refactor to generic Storage #189
Conversation
onmyway133
commented
Jun 13, 2018
- This enables more generic usage for Codable, Image and other types with flexible transformers
- Ensure type safety
- No need for ImageWrapper ImageWrapper overhead #174
- Use document directory by default Shouldn't the default cache folder be /library or /documents not /library/caches? #179
…lo/Cache into refactor/generic_storage * 'refactor/generic_storage' of https://github.com/hyperoslo/Cache: Default to document directory
Using document directory won’t work on tvOS I think. You should test that. |
@zenangst All tests have passed for both iOS and tvOS. Did you have a problem with tvOS ? |
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.
@onmyway133 Great work! We should update README as well to make it clear how to use the new API.
public extension DiskStorage { | ||
func transform<U>(transformer: Transformer<U>) -> DiskStorage<U> { | ||
// swiftlint:disable force_try | ||
let storage = try! DiskStorage<U>( |
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.
Is it safe to use force try here?
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.
I can improve this in the next PR
@onmyway133 I think using Document directory by default is not a good idea, I would leave cache. Read #179 (comment). As for tvOS I think it won't work on the device. |
@onmyway133 the problem is on device not in the simulator. I ran into issues that the app would throw and exception and crash when trying to store files in the app directory. However, it worked just fine in the simulator and tests. Just to be sure, I’d install it on a device just to make sure that everything is dandy and fine. It worked with cache before as it used the apps cache directory instead of documents, which is allowed to modify. The issue with the cache directory is that images etc will be wiped the next time the application will run. Maybe that is something that is desired but it kinda throws the expiration feature out the window. |
@zenangst Yeah thanks for the advice. I've set back to using document directory. We have configuration with custom directory so I think that should be fine for user with more customised scenario. |