Ensure snapshot overwrite protection if host time is incorrect

next
Sayan Nandan 3 years ago
parent 0e10f2cb5f
commit 2c6768dc12
No known key found for this signature in database
GPG Key ID: 8BC07A0A4D41DD52

@ -37,6 +37,9 @@ All changes in this project will be noted in this file.
save on termination routine
- Fixed bug that prevented tree cleanup from working
- Disallow `PRELOAD` and `PARTMAP` as entity names
- Fixed edge case where time on host is incorrect, resulting in bad snapshot names which might
ultimately lead to loss of snapshot data
- Fixed remote snapshots with same names being overwritten
## Version 0.7.4

@ -39,6 +39,7 @@ use regex::Regex;
use std::collections::HashSet;
use std::fs;
use std::io::Error as IoError;
use std::path::Path;
use std::sync::Arc;
type QStore = IArray<[String; 64]>;
@ -164,9 +165,13 @@ impl SnapshotEngine {
Utc::now().format("%Y%m%d-%H%M%S").to_string()
}
fn _mksnap_blocking_section(store: &Memstore, name: String) -> SnapshotResult<()> {
let snapshot = LocalSnapshot::new(name);
super::flush::flush_full(snapshot, store)?;
Ok(())
if Path::new(&format!("{DIR_SNAPROOT}/{name}")).exists() {
Err(SnapshotEngineError::Engine("Server time is incorrect"))
} else {
let snapshot = LocalSnapshot::new(name);
super::flush::flush_full(snapshot, store)?;
Ok(())
}
}
fn _rmksnap_blocking_section(store: &Memstore, name: &str) -> SnapshotResult<()> {
let snapshot = RemoteSnapshot::new(name);

Loading…
Cancel
Save