Shows full path in case of a File Exists error

When the system tries to create the configuration directories,
it crashes if it fails (say because of regular file there or
a broken symlink). The out put is "File Exists" which makes
troubleshooting difficult.

With this change, gossip prints the full path of the
problematic file so the user khows where to look.

fixes #856
This commit is contained in:
Jadi 2024-09-14 18:43:41 +03:30
parent 64ae9a4ba3
commit 0a946b2597

View File

@ -112,10 +112,22 @@ impl Profile {
};
// Create all these directories if missing
fs::create_dir_all(&base_dir)?;
fs::create_dir_all(&cache_dir)?;
fs::create_dir_all(&profile_dir)?;
fs::create_dir_all(&lmdb_dir)?;
fs::create_dir_all(&base_dir).map_err(|e| {
eprintln!("Error creating base directory ({}): {}", base_dir.display(), e);
Error::from(format!("Failed to create base directory: {}", e))
})?;
fs::create_dir_all(&cache_dir).map_err(|e| {
eprintln!("Error creating cache directory ({}): {}", cache_dir.display(), e);
Error::from(format!("Failed to create cache directory: {}", e))
})?;
fs::create_dir_all(&profile_dir).map_err(|e| {
eprintln!("Error creating profile directory ({}): {}", profile_dir.display(), e);
Error::from(format!("Failed to create profile directory: {}", e))
})?;
fs::create_dir_all(&lmdb_dir).map_err(|e| {
eprintln!("Error creating LMDB directory ({}): {}", lmdb_dir.display(), e);
Error::from(format!("Failed to create LMDB directory: {}", e))
})?;
let tmp_cache_dir = TempDir::new("cache")?;