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(http): persist cookies on disk #1978

Open
wants to merge 7 commits into
base: v2
Choose a base branch
from
Open

Conversation

amrbashir
Copy link
Member

@amrbashir amrbashir commented Oct 28, 2024

@amrbashir amrbashir requested a review from a team as a code owner October 28, 2024 14:54
Copy link
Contributor

github-actions bot commented Oct 28, 2024

Package Changes Through 10ce353

There are 4 changes which include log with patch, log-js with patch, http with patch, http-js with patch

Planned Package Versions

The following package releases are the planned based on the context of changes in this pull request.

package current next
api-example 2.0.6 2.0.7
api-example-js 2.0.3 2.0.4
http 2.0.4 2.0.5
http-js 2.0.1 2.0.2
log 2.0.3 2.0.4
log-js 2.0.1 2.0.2

Add another change file through the GitHub UI by following this link.


Read about change files or the docs at github.com/jbolda/covector

@amrbashir amrbashir changed the title enhance(http): persist cookies on disk feat(http): persist cookies on disk Oct 28, 2024
let cache_dir = app.path().app_cache_dir()?;
std::fs::create_dir_all(&cache_dir)?;

let path = cache_dir.join("Cookies");

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"[]")?;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants