Skip to content

Commit

Permalink
Merge pull request #318 from lucab/ups/create_dir_empty_ssh_keys
Browse files Browse the repository at this point in the history
sshkeys: fix missing directory on empty set
  • Loading branch information
Luca Bruno authored Nov 29, 2019
2 parents e8af47e + 093bcb7 commit 60b566a
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/providers/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,11 +154,12 @@ fn write_ssh_keys(user: User, ssh_keys: Vec<PublicKey>) -> Result<()> {
}

// sync parent dir to persist updates
let dir_file = File::open(&dir_path)
.chain_err(|| format!("failed to open {:?} for syncing", dir_path.display()))?;
dir_file
.sync_all()
.chain_err(|| format!("failed to sync {:?}", dir_path.display()))?;
match File::open(&dir_path) {
Ok(dir_file) => dir_file.sync_all(),
Err(ref e) if e.kind() == NotFound => Ok(()),
Err(e) => Err(e),
}
.chain_err(|| format!("failed to sync '{}'", dir_path.display()))?;

// make clippy happy while fulfilling our interface
drop(user);
Expand Down

0 comments on commit 60b566a

Please sign in to comment.