mirror of
https://codeberg.org/icewind/log-archiver.git
synced 2026-06-03 17:44:06 +02:00
subfolders
This commit is contained in:
parent
cda4744106
commit
4cb1369d2b
1 changed files with 19 additions and 1 deletions
20
src/main.rs
20
src/main.rs
|
|
@ -123,12 +123,30 @@ async fn download_log(
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
if let Err(e) = archive.extract(&log_target) {
|
if let Err(e) = archive.extract(log_path(log_target, id)) {
|
||||||
eprintln!("Error extracting log: {:#}", e);
|
eprintln!("Error extracting log: {:#}", e);
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn log_path<P: AsRef<Path>>(log_target: P, id: i32) -> PathBuf {
|
||||||
|
log_target.as_ref().join(format!(
|
||||||
|
"{:07}/{:07}",
|
||||||
|
id / 1_000_000 * 1_000_000,
|
||||||
|
id / 1_000 * 1_000
|
||||||
|
))
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_log_path() {
|
||||||
|
assert_eq!(
|
||||||
|
PathBuf::from("foo/2000000/2123000"),
|
||||||
|
log_path("foo", 2123456)
|
||||||
|
);
|
||||||
|
assert_eq!(PathBuf::from("foo/0000000/0000000"), log_path("foo", 2));
|
||||||
|
assert_eq!(PathBuf::from("foo/0000000/0001000"), log_path("foo", 1_002));
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug, Deserialize)]
|
#[derive(Debug, Deserialize)]
|
||||||
struct LogListing {
|
struct LogListing {
|
||||||
success: bool,
|
success: bool,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue