src/api2/admin/datastore/backup/environment.rs: do not allow empty backups (no files)
This commit is contained in:
parent
39e60bd6fa
commit
e6389f4e75
@ -29,6 +29,7 @@ struct FixedWriterState {
|
|||||||
struct SharedBackupState {
|
struct SharedBackupState {
|
||||||
finished: bool,
|
finished: bool,
|
||||||
uid_counter: usize,
|
uid_counter: usize,
|
||||||
|
file_counter: usize, // sucessfully uploaded files
|
||||||
dynamic_writers: HashMap<usize, DynamicWriterState>,
|
dynamic_writers: HashMap<usize, DynamicWriterState>,
|
||||||
fixed_writers: HashMap<usize, FixedWriterState>,
|
fixed_writers: HashMap<usize, FixedWriterState>,
|
||||||
known_chunks: HashMap<[u8;32], u32>,
|
known_chunks: HashMap<[u8;32], u32>,
|
||||||
@ -79,6 +80,7 @@ impl BackupEnvironment {
|
|||||||
let state = SharedBackupState {
|
let state = SharedBackupState {
|
||||||
finished: false,
|
finished: false,
|
||||||
uid_counter: 0,
|
uid_counter: 0,
|
||||||
|
file_counter: 0,
|
||||||
dynamic_writers: HashMap::new(),
|
dynamic_writers: HashMap::new(),
|
||||||
fixed_writers: HashMap::new(),
|
fixed_writers: HashMap::new(),
|
||||||
known_chunks: HashMap::new(),
|
known_chunks: HashMap::new(),
|
||||||
@ -218,6 +220,8 @@ impl BackupEnvironment {
|
|||||||
|
|
||||||
data.index.close()?;
|
data.index.close()?;
|
||||||
|
|
||||||
|
state.file_counter += 1;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -248,6 +252,8 @@ impl BackupEnvironment {
|
|||||||
|
|
||||||
data.index.close()?;
|
data.index.close()?;
|
||||||
|
|
||||||
|
state.file_counter += 1;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -264,6 +270,10 @@ impl BackupEnvironment {
|
|||||||
bail!("found open index writer - unable to finish backup");
|
bail!("found open index writer - unable to finish backup");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if state.file_counter == 0 {
|
||||||
|
bail!("backup does not contain valid files (file count == 0)");
|
||||||
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user