Skip to content
This repository has been archived by the owner on Feb 3, 2023. It is now read-only.

Commit

Permalink
Merge pull request #11 from approvers/empty-version-as-error
Browse files Browse the repository at this point in the history
Handle empty version as deserialize error
  • Loading branch information
siketyan authored Jul 12, 2020
2 parents 415b8a6 + 70135dd commit ac696bb
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/migration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ use crate::filesystem;

#[derive(Deserialize)]
struct Outline {
version: Option<u32>,
version: u32,
}

pub fn migrate(path: &str) -> Result<(), Error> {
let mut yaml = filesystem::open(path);

loop {
let outline: Result<Outline, Error> = serde_yaml::from_str(&yaml);
let version = outline.map_or(None, |o| o.version).unwrap_or(0);
let version = outline.map_or(0, |o| o.version);

yaml = match version {
0 => version_0001_uuid::up(&yaml)?,
Expand Down

0 comments on commit ac696bb

Please sign in to comment.