diff --git a/src/api2/admin/datastore/backup/environment.rs b/src/api2/admin/datastore/backup/environment.rs index c6b48053..845a5946 100644 --- a/src/api2/admin/datastore/backup/environment.rs +++ b/src/api2/admin/datastore/backup/environment.rs @@ -29,6 +29,7 @@ struct FixedWriterState { struct SharedBackupState { finished: bool, uid_counter: usize, + file_counter: usize, // sucessfully uploaded files dynamic_writers: HashMap, fixed_writers: HashMap, known_chunks: HashMap<[u8;32], u32>, @@ -79,6 +80,7 @@ impl BackupEnvironment { let state = SharedBackupState { finished: false, uid_counter: 0, + file_counter: 0, dynamic_writers: HashMap::new(), fixed_writers: HashMap::new(), known_chunks: HashMap::new(), @@ -218,6 +220,8 @@ impl BackupEnvironment { data.index.close()?; + state.file_counter += 1; + Ok(()) } @@ -248,6 +252,8 @@ impl BackupEnvironment { data.index.close()?; + state.file_counter += 1; + Ok(()) } @@ -264,6 +270,10 @@ impl BackupEnvironment { 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(()) }