Browse Source

Properly recover from error opening file

At first I thought the `map_err` would be the right way to solve this,
but actually it didn't do what I expected.
master
Julio Biason 4 years ago
parent
commit
a1bf236a83
  1. 6
      src/storage/org.rs

6
src/storage/org.rs

@ -52,7 +52,7 @@ impl Storage for Org {
.write(true)
.append(true)
.open(&self.file)
.map_err(|_| {
.unwrap_or_else(|_| {
// Let's assume here that the problem is that the file doesn't exist.
log::debug!(
"Creating {filename}",
@ -68,8 +68,8 @@ impl Storage for Org {
fp.write_all(text.as_bytes()).unwrap();
fp
})
})
.unwrap();
.unwrap()
});
fp.write_all(
format!(
"* {user}/{id}\n {message}\n",

Loading…
Cancel
Save