Skip to content

Commit

Permalink
πŸ‘€ Verify TOML format when checking UUID file
Browse files Browse the repository at this point in the history
  • Loading branch information
phoenixr-codes committed Apr 18, 2024
1 parent 0dc562f commit adeca62
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/health.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,17 @@ impl Health {

pub fn check_uuids(&self) -> bool {
let uuids = self.root.join(paths::uuids());
// TODO: validate file format
if uuids.exists() {
let valid_file_format: bool = (|| {
toml::from_str::<toml::Value>(match fs::read_to_string(&uuids) {
Ok(ref data) => &data,
Err(e) => {
log::error!("Failed to read UUID file: {}", e);
return false;
}
})
.is_ok()
})();
if uuids.exists() && valid_file_format {
true
} else if self.fix {
log::info!("Fix missing UUIDs");
Expand Down

0 comments on commit adeca62

Please sign in to comment.