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

feat: add ParseFile caching using download folder #416

Merged
merged 5 commits into from
Sep 15, 2022

Conversation

cbaker6
Copy link
Contributor

@cbaker6 cbaker6 commented Sep 15, 2022

New Pull Request Checklist

Issue Description

#414 removed file caching from the SDK because it was broken. It also discussed a strategy where developers can check the download directory for files that were already saved.

If the Swift SDK automatically checked the file download folder and returned the file based on the passed cache policy, it would make it easier for developers and reduce network overhead from downloading files that are already saved locally.

Related issue: #413, #226

Approach

Use the Parse download folder as cache. This can work because all ParseFile names are unique and files are in the same directory.

Note

ParseFile's are not deleted from the downloads folder automatically. If developers want to delete files manually they can take advantage of two new type methods: ParseFileManager.downloadDirectory() and ParseFileManager.fileExists(). Then they can use the native FileManager.default.removeItem() to remove a particular file.

TODOs before merging

  • Add tests
  • Add entry to changelog
  • Add changes to documentation (guides, repository pages, in-code descriptions)

@parse-github-assistant
Copy link

parse-github-assistant bot commented Sep 15, 2022

Thanks for opening this pull request!

  • 🎉 We are excited about your hands-on contribution!

@codecov
Copy link

codecov bot commented Sep 15, 2022

Codecov Report

Base: 90.06% // Head: 90.13% // Increases project coverage by +0.07% 🎉

Coverage data is based on head (301005e) compared to base (e54a22c).
Patch coverage: 98.60% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #416      +/-   ##
==========================================
+ Coverage   90.06%   90.13%   +0.07%     
==========================================
  Files         159      159              
  Lines       15308    15322      +14     
==========================================
+ Hits        13787    13811      +24     
+ Misses       1521     1511      -10     
Impacted Files Coverage Δ
Sources/ParseSwift/Parse.swift 99.02% <ø> (ø)
...es/ParseSwift/Protocols/ParseCloudable+async.swift 100.00% <ø> (ø)
.../ParseSwift/Protocols/ParseCloudable+combine.swift 100.00% <ø> (ø)
Sources/ParseSwift/Protocols/ParseCloudable.swift 100.00% <ø> (ø)
...ources/ParseSwift/Storage/ParseKeyValueStore.swift 97.22% <ø> (ø)
Sources/ParseSwift/Types/CloudViewModel.swift 100.00% <ø> (ø)
Sources/ParseSwift/Types/ParseConfiguration.swift 53.06% <ø> (ø)
Sources/ParseSwift/Types/ParseFile+async.swift 100.00% <ø> (ø)
Sources/ParseSwift/Storage/ParseFileManager.swift 92.82% <92.59%> (+0.24%) ⬆️
Sources/ParseSwift/API/API+Command.swift 89.57% <100.00%> (-0.25%) ⬇️
... and 5 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@cbaker6 cbaker6 merged commit 085f5ad into parse-community:main Sep 15, 2022
@cbaker6 cbaker6 deleted the fileCache branch September 15, 2022 21:16
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

Successfully merging this pull request may close these issues.

None yet

1 participant