vault: relative_dir drops the redundant is_absolute arm; test an import that cannot publish
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
b1a2d05976
commit
03fb33fb93
1 changed files with 16 additions and 4 deletions
|
|
@ -406,10 +406,9 @@ fn hex(bytes: &[u8]) -> String {
|
|||
/// when it is absolute or holds anything but plain components.
|
||||
fn relative_dir(text: &str) -> Option<String> {
|
||||
let path = Path::new(text.trim());
|
||||
if path.is_absolute()
|
||||
|| path
|
||||
.components()
|
||||
.any(|part| !matches!(part, Component::Normal(_)))
|
||||
if path
|
||||
.components()
|
||||
.any(|part| !matches!(part, Component::Normal(_)))
|
||||
{
|
||||
return None;
|
||||
}
|
||||
|
|
@ -1482,6 +1481,19 @@ mod tests {
|
|||
}
|
||||
}
|
||||
|
||||
/// An import that cannot publish says so: a directory squatting on the
|
||||
/// snapshot's name is an error, not a snapshot already held.
|
||||
#[test]
|
||||
fn an_import_that_cannot_publish_is_an_error() {
|
||||
let vault = fixture();
|
||||
let built = snapshot(vault.path());
|
||||
let store = tempfile::tempdir().unwrap();
|
||||
let squatter = store.path().join(format!("{}.cc", built.id()));
|
||||
std::fs::create_dir_all(squatter.join("inside")).unwrap();
|
||||
assert!(matches!(built.import_into(store.path()), Err(VaultError::Store)));
|
||||
assert_eq!(listing(store.path()), [format!("{}.cc", built.id())]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn load_leaves_the_store_directory_as_it_found_it() {
|
||||
let vault = fixture();
|
||||
|
|
|
|||
Loading…
Reference in a new issue