Don't recognize temp snapshots as possible snapshots to open
(cherry picked from commit 3e0fed48e7
)
This commit is contained in:
committed by
Michael Vines
parent
7600be946a
commit
9761af201b
@ -660,7 +660,7 @@ fn archive_format_from_str(archive_format: &str) -> Option<ArchiveFormat> {
|
||||
|
||||
fn snapshot_hash_of(archive_filename: &str) -> Option<(Slot, Hash, ArchiveFormat)> {
|
||||
let snapshot_filename_regex =
|
||||
Regex::new(r"snapshot-(\d+)-([[:alnum:]]+)\.(tar|tar\.bz2|tar\.zst|tar\.gz)$").unwrap();
|
||||
Regex::new(r"^snapshot-(\d+)-([[:alnum:]]+)\.(tar|tar\.bz2|tar\.zst|tar\.gz)$").unwrap();
|
||||
|
||||
if let Some(captures) = snapshot_filename_regex.captures(archive_filename) {
|
||||
let slot_str = captures.get(1).unwrap().as_str();
|
||||
@ -1136,6 +1136,12 @@ mod tests {
|
||||
snapshot_hash_of(&format!("snapshot-42-{}.tar", Hash::default())),
|
||||
Some((42, Hash::default(), ArchiveFormat::Tar))
|
||||
);
|
||||
assert!(snapshot_hash_of(&format!(
|
||||
"{}snapshot-42-{}.tar",
|
||||
TMP_SNAPSHOT_PREFIX,
|
||||
Hash::default()
|
||||
))
|
||||
.is_none());
|
||||
|
||||
assert!(snapshot_hash_of("invalid").is_none());
|
||||
}
|
||||
|
Reference in New Issue
Block a user