Skip to content

Commit 11f6098

Browse files
author
Devdutt Shenoi
authored
fix: bridge failure to shutdown on file permission denied (#243)
* feat: print `persistence_path` in banner * fix: permission denied causes bridge only failure
1 parent 28a109a commit 11f6098

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed

uplink/src/base/bridge/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,6 @@ impl Bridge {
267267
None => return Ok(()),
268268
};
269269
let mut path = self.config.persistence_path.clone();
270-
fs::create_dir_all(&path)?;
271270
path.push("current_action");
272271
info!("Storing current action in persistence; path: {}", path.display());
273272
current_action.write_to_disk(path)?;

uplink/src/lib.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,14 @@ pub mod config {
158158

159159
let mut config: Config = config.try_deserialize()?;
160160

161+
// Create directory at persistence_path if it doesn't already exist
162+
fs::create_dir_all(&config.persistence_path).map_err(|_| {
163+
anyhow::Error::msg(format!(
164+
"Permission denied for creating persistence directory at \"{}\"",
165+
config.persistence_path.display()
166+
))
167+
})?;
168+
161169
// replace placeholders with device/tenant ID
162170
let tenant_id = config.project_id.trim();
163171
let device_id = config.device_id.trim();

uplink/src/main.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ fn banner(commandline: &CommandLine, config: &Arc<Config>) {
6868
println!(" project_id: {}", config.project_id);
6969
println!(" device_id: {}", config.device_id);
7070
println!(" remote: {}:{}", config.broker, config.port);
71+
println!(" persistence_path: {}", config.persistence_path.display());
7172
if !config.action_redirections.is_empty() {
7273
println!(" action redirections:");
7374
for (action, redirection) in config.action_redirections.iter() {

0 commit comments

Comments
 (0)