mirror of
https://github.com/FliegendeWurst/KIT-ILIAS-downloader.git
synced 2024-08-28 04:04:18 +00:00
Actually save session cookies
the cookie store crate by default only saves persistent cookies ...
This commit is contained in:
parent
daa9bdbfa4
commit
6ea00d5f59
@ -1,6 +1,6 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
use std::{error::Error as _, sync::Arc};
|
||||
use std::{error::Error as _, io::Write, sync::Arc};
|
||||
|
||||
use anyhow::{anyhow, Context, Result};
|
||||
use colored::Colorize;
|
||||
@ -138,7 +138,11 @@ impl ILIAS {
|
||||
let session_path = self.opt.output.join(".iliassession");
|
||||
let mut writer = std::fs::File::create(session_path).map(std::io::BufWriter::new).unwrap();
|
||||
let store = self.cookies.lock().map_err(|x| anyhow!("{}", x))?;
|
||||
store.save_json(&mut writer).map_err(|x| anyhow!(x))?;
|
||||
// save all cookies, including session cookies
|
||||
for cookie in store.iter_unexpired().map(serde_json::to_string) {
|
||||
writeln!(writer, "{}", cookie?)?;
|
||||
}
|
||||
writer.flush()?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user