Initial stabilization #1
1 changed files with 21 additions and 7 deletions
fix: correct directory entry handling
All checks were successful
Build and update the action / build-and-upload (push) Successful in 2m34s
All checks were successful
Build and update the action / build-and-upload (push) Successful in 2m34s
- do not warn about double file if contained files are seen before the directory itself - do not warn about unused file if directory entry is not found
commit
9a9032f358
28
src/main.rs
28
src/main.rs
|
|
@ -23,7 +23,7 @@ struct Input {
|
|||
key: CacheKey,
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
#[derive(Debug, PartialEq, Clone, Copy)]
|
||||
enum PathState {
|
||||
Unused,
|
||||
File,
|
||||
|
|
@ -62,22 +62,36 @@ fn main() -> Result<()> {
|
|||
entry_path.push(entry.path().context("reading entry path")?.as_ref());
|
||||
if let Some(state) = paths.get_mut(&entry_path) {
|
||||
// exact match on one of cached paths
|
||||
match core::mem::replace(state, PathState::File) {
|
||||
PathState::Unused => {
|
||||
let new_state = if entry.header().entry_type().is_dir() {
|
||||
PathState::Directory
|
||||
} else {
|
||||
PathState::File
|
||||
};
|
||||
// match on (old, new)
|
||||
match (core::mem::replace(state, new_state), new_state) {
|
||||
(PathState::Unused, _) => {
|
||||
// a previously-unseen entry, unpack normally
|
||||
entry.unpack(&entry_path).context("writing cache entry")?;
|
||||
}
|
||||
PathState::File => {
|
||||
(PathState::File, PathState::File) => {
|
||||
println!("warn: double file in the archive: {}", entry_path.display());
|
||||
}
|
||||
(PathState::Directory, PathState::Directory) => {
|
||||
// entry could be marked as directory because of previous contained file entries; nothing to warn about here
|
||||
}
|
||||
(PathState::Directory, PathState::File) => {
|
||||
println!(
|
||||
"warn: double entry in the archive: {}",
|
||||
entry_path.display()
|
||||
"WARN: found a directory path that was previously assumed to be a regular file: {}",
|
||||
directory_path.display()
|
||||
);
|
||||
}
|
||||
PathState::Directory => {
|
||||
(PathState::File, PathState::Directory) => {
|
||||
println!(
|
||||
"WARN: found a regular file that was previously assumed to be a directory: {}",
|
||||
entry_path.display()
|
||||
);
|
||||
}
|
||||
(_, PathState::Unused) => unreachable!(),
|
||||
}
|
||||
}
|
||||
if let Some(directory) = paths.keys().find(|p| entry_path.starts_with(p)) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue