-
Notifications
You must be signed in to change notification settings - Fork 431
feat(http): persist cookies on disk #1978
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
Conversation
Package Changes Through 3d8ce8eThere are 2 changes which include http with patch, http-js with patch Planned Package VersionsThe following package releases are the planned based on the context of changes in this pull request.
Add another change file through the GitHub UI by following this link. Read about change files or the docs at github.com/jbolda/covector |
plugins/http/src/lib.rs
Outdated
let cache_dir = app.path().app_cache_dir()?; | ||
std::fs::create_dir_all(&cache_dir)?; | ||
|
||
let path = cache_dir.join("Cookies"); |
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.
Just FYI. I have been testing this and this part seems to break when the "Cookies" did not previously exist.
I changed it so it starts with an empty array in case the file is new:
let path = cache_dir.join("Cookies");
let file_exists = path.exists();
let mut file = File::options()
.create(true)
.append(true)
.read(true)
.open(&path)?;
if !file_exists {
// Initialize the file with an empty array
use std::io::Write;
file.write_all(b"[]")?;
}
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.
nice catch!
* enhance(http): persist cookies on disk closes tauri-apps/tauri#11518 * clippy * inline reqwest_cookie_store to fix clippy * clippy * Update .changes/persist-cookies.md * Update plugins/http/src/reqwest_cookie_store.rs * update example * fallback to empty store if failed to load * fix example * persist cookies immediately * clone * lint * .cookies filename * prevent race condition --------- Co-authored-by: Lucas Nogueira <[email protected]>
* enhance(http): persist cookies on disk closes tauri-apps/tauri#11518 * clippy * inline reqwest_cookie_store to fix clippy * clippy * Update .changes/persist-cookies.md * Update plugins/http/src/reqwest_cookie_store.rs * update example * fallback to empty store if failed to load * fix example * persist cookies immediately * clone * lint * .cookies filename * prevent race condition --------- Co-authored-by: Lucas Nogueira <[email protected]>
closes tauri-apps/tauri#11518
closes #2375