Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
LeChatP committed May 5, 2024
1 parent acb89b3 commit 99764d2
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions src/sr/timeout.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::{
error::Error,
fs::{self, File},
fs,
io::{BufReader, Read, Write},
path::Path,
thread::sleep,
Expand All @@ -17,7 +17,7 @@ use serde::{Deserialize, Serialize};
use tracing::debug;

use crate::common::{
create_with_privileges,
create_with_privileges, dac_override_effective,
database::{
finder::Cred,
options::{STimeout, TimestampType},
Expand Down Expand Up @@ -177,7 +177,16 @@ fn read_cookies(user: &Cred) -> Result<Vec<CookieVersion>, Box<dyn Error>> {

fn save_cookies(user: &Cred, cookies: &[CookieVersion]) -> Result<(), Box<dyn Error>> {
let path = Path::new(TS_LOCATION).join(&user.user.name);
fs::create_dir_all(path.parent().unwrap())?;
fs::create_dir_all(path.parent().unwrap()).or_else(|e| {
debug!(

Check warning on line 181 in src/sr/timeout.rs

View check run for this annotation

Codecov / codecov/patch

src/sr/timeout.rs#L180-L181

Added lines #L180 - L181 were not covered by tests
"Failed to create directory for cookies: {}, trying with privileges",
e
);
dac_override_effective(true)?;
let res = fs::create_dir_all(path.parent().unwrap());
dac_override_effective(false)?;
res

Check warning on line 188 in src/sr/timeout.rs

View check run for this annotation

Codecov / codecov/patch

src/sr/timeout.rs#L185-L188

Added lines #L185 - L188 were not covered by tests
})?;
let lockpath = Path::new(TS_LOCATION)
.join(&user.user.name)
.with_extension("lock");
Expand Down Expand Up @@ -230,8 +239,8 @@ fn find_valid_cookie(
for a in to_remove {
cookies.remove(a);
}
if save_cookies(from, &cookies).is_err() {
debug!("Failed to save cookies");
if let Err(e) = save_cookies(from, &cookies) {
debug!("Failed to save cookies {:?}",e);

Check warning on line 243 in src/sr/timeout.rs

View check run for this annotation

Codecov / codecov/patch

src/sr/timeout.rs#L242-L243

Added lines #L242 - L243 were not covered by tests
}
res
}
Expand Down

0 comments on commit 99764d2

Please sign in to comment.