Compare commits

..
Author SHA1 Message Date
dzu
0a6d564393 fix: correct handling for absolute paths
All checks were successful
Build and update the action / build-and-upload (push) Successful in 2m36s
2026-02-21 10:43:32 +00:00
dzu
8e94974bef upd: bump common crate to v3 2026-02-21 10:33:48 +00:00
dzu
552ecb6f5d upd: common crate bump to main branch 2026-02-21 03:10:52 +00:00
dzu
b57526eff4 rel: lock dependencies 2026-02-20 15:15:27 +00:00
3 changed files with 38 additions and 33 deletions

10
Cargo.lock generated
View file

@ -11,7 +11,7 @@ checksum = "320119579fcad9c21884f5c4861d16174d0e06250625266f50fe6898340abefa"
[[package]] [[package]]
name = "anode" name = "anode"
version = "0.1.0" version = "0.1.0"
source = "git+https://git.dzuchun.ing/dzu/anode.git#98addf4d54ae16c21979a1dae63d17738b3a277b" source = "git+https://git.dzuchun.ing/dzu/anode.git?tag=v1#98addf4d54ae16c21979a1dae63d17738b3a277b"
dependencies = [ dependencies = [
"anode-macros", "anode-macros",
"thiserror", "thiserror",
@ -20,7 +20,7 @@ dependencies = [
[[package]] [[package]]
name = "anode-build" name = "anode-build"
version = "0.1.0" version = "0.1.0"
source = "git+https://git.dzuchun.ing/dzu/anode.git#98addf4d54ae16c21979a1dae63d17738b3a277b" source = "git+https://git.dzuchun.ing/dzu/anode.git?tag=v1#98addf4d54ae16c21979a1dae63d17738b3a277b"
dependencies = [ dependencies = [
"anode-macros-input", "anode-macros-input",
"quote", "quote",
@ -32,7 +32,7 @@ dependencies = [
[[package]] [[package]]
name = "anode-cache-common" name = "anode-cache-common"
version = "0.1.0" version = "0.1.0"
source = "git+https://git.dzuchun.ing/actions/cache-common-src.git#479d6fe4149b1cc4c81486fdf0eb6f6a56fc9282" source = "git+https://git.dzuchun.ing/actions/cache-common-src.git?tag=v3#a460ddb58f8b2006a9edfd231d12882cc95bcca0"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"isahc", "isahc",
@ -46,7 +46,7 @@ dependencies = [
[[package]] [[package]]
name = "anode-macros" name = "anode-macros"
version = "0.1.0" version = "0.1.0"
source = "git+https://git.dzuchun.ing/dzu/anode.git#98addf4d54ae16c21979a1dae63d17738b3a277b" source = "git+https://git.dzuchun.ing/dzu/anode.git?tag=v1#98addf4d54ae16c21979a1dae63d17738b3a277b"
dependencies = [ dependencies = [
"anode-macros-input", "anode-macros-input",
"proc-macro2", "proc-macro2",
@ -58,7 +58,7 @@ dependencies = [
[[package]] [[package]]
name = "anode-macros-input" name = "anode-macros-input"
version = "0.1.0" version = "0.1.0"
source = "git+https://git.dzuchun.ing/dzu/anode.git#98addf4d54ae16c21979a1dae63d17738b3a277b" source = "git+https://git.dzuchun.ing/dzu/anode.git?tag=v1#98addf4d54ae16c21979a1dae63d17738b3a277b"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",

View file

@ -4,16 +4,23 @@ version = "0.1.0"
edition = "2024" edition = "2024"
[dependencies] [dependencies]
anode = { git = "https://git.dzuchun.ing/dzu/anode.git", version = "0.1.0" }
anode-cache-common = { git = "https://git.dzuchun.ing/actions/cache-common-src.git", version = "0.1.0" }
anyhow = "1.0.101" anyhow = "1.0.101"
flate2 = "1.1.9" flate2 = "1.1.9"
secrecy = "0.10.3" secrecy = "0.10.3"
tar = "0.4.44" tar = "0.4.44"
tracing = { version = "0.1.44", features = ["attributes"] } tracing = { version = "0.1.44", features = ["attributes"] }
[build-dependencies] [dependencies.anode]
anode-build = { git = "https://git.dzuchun.ing/dzu/anode.git", version = "0.1.0" } git = "https://git.dzuchun.ing/dzu/anode.git"
tag = "v1"
[dependencies.anode-cache-common]
git = "https://git.dzuchun.ing/actions/cache-common-src.git"
tag = "v3"
[build-dependencies.anode-build]
git = "https://git.dzuchun.ing/dzu/anode.git"
tag = "v1"
[profile.release] [profile.release]
opt-level = "s" opt-level = "s"

View file

@ -59,25 +59,26 @@ fn main() -> Result<()> {
let in_uncomp = GzDecoder::new(&mut cache); let in_uncomp = GzDecoder::new(&mut cache);
let mut archive = Archive::new(in_uncomp); let mut archive = Archive::new(in_uncomp);
debug!(paths = ?path); let common = anode_cache_common::common_parent(&path);
let mut paths = path debug!(common_path = %common.display(), paths = ?path);
.into_iter() let mut names = path
.map(|p| (p, PathState::Unused)) .iter()
.map(|p| (p.strip_prefix(&common).unwrap(), (p, PathState::Unused)))
.collect::<HashMap<_, _>>(); .collect::<HashMap<_, _>>();
// tmp buffers // tmp buffers
let mut entry_path_buf = PathBuf::new(); let mut entry_name_buf = PathBuf::new();
let mut directory_path_buf = PathBuf::new(); let mut directory_name_buf = PathBuf::new();
for entry in archive.entries().context("reading cache entries")? { for entry in archive.entries().context("reading cache entries")? {
let mut entry = entry.context("reading cache entry")?; let mut entry = entry.context("reading cache entry")?;
{ {
let entry_path = entry.path().context("reading entry path")?; let entry_name = entry.path().context("reading entry path")?;
entry_path_buf.clear(); entry_name_buf.clear();
entry_path_buf.push(&entry_path); entry_name_buf.push(&entry_name);
} }
let _span = info_span!("archive-entry", path = %entry_path_buf.display()); let _span = info_span!("archive-entry", name = %entry_name_buf.display());
let _span = _span.enter(); let _span = _span.enter();
if let Some(state) = paths.get_mut(&entry_path_buf) { if let Some((output_path, state)) = names.get_mut(&*entry_name_buf) {
let new_state = if entry.header().entry_type().is_dir() { let new_state = if entry.header().entry_type().is_dir() {
PathState::Directory PathState::Directory
} else { } else {
@ -87,9 +88,7 @@ fn main() -> Result<()> {
// match on (old, new) // match on (old, new)
match (core::mem::replace(state, new_state), new_state) { match (core::mem::replace(state, new_state), new_state) {
(PathState::Unused, _) => { (PathState::Unused, _) => {
entry entry.unpack(*output_path).context("writing cache entry")?;
.unpack(&entry_path_buf)
.context("writing cache entry")?;
debug!("Unpacked normally"); debug!("Unpacked normally");
} }
(PathState::File, PathState::File) => { (PathState::File, PathState::File) => {
@ -107,18 +106,17 @@ fn main() -> Result<()> {
} }
(_, PathState::Unused) => unreachable!(), (_, PathState::Unused) => unreachable!(),
} }
} else if let Some(directory) = paths.keys().find(|p| entry_path_buf.starts_with(p)) { } else if let Some(directory) = names.keys().find(|p| entry_name_buf.starts_with(p)) {
debug!(directory = %directory.display(), "File in a directory"); debug!(directory = %directory.display(), "File in a directory");
directory_path_buf.clone_from(directory); directory_name_buf.clear();
directory_name_buf.push(directory);
// file in a cached directory // file in a cached directory
let state = paths let (output_path, state) = names
.get_mut(&directory_path_buf) .get_mut(&*directory_name_buf)
.expect("paths should contain a path that was just extracted as a key"); .expect("name should contain a name that was just extracted as a key");
match core::mem::replace(state, PathState::Directory) { match core::mem::replace(state, PathState::Directory) {
PathState::Unused | PathState::Directory => { PathState::Unused | PathState::Directory => {
entry entry.unpack(*output_path).context("writing cache entry")?;
.unpack(&entry_path_buf)
.context("writing cache entry")?;
debug!("Unpacked normally"); debug!("Unpacked normally");
} }
PathState::File => { PathState::File => {
@ -130,9 +128,9 @@ fn main() -> Result<()> {
} }
} }
for (path, state) in paths { for (path, (name, state)) in names {
if state == PathState::Unused { if state == PathState::Unused {
warn!(path = %path.display(), "Cached path was not found in the cache",); warn!(path = %path.display(), name = %name.display(), "Cached path was not found in the cache",);
} }
} }