Skip to content

Commit

Permalink
replace unwrap with map_err and ok_or_else
Browse files Browse the repository at this point in the history
  • Loading branch information
xiangzhu70 committed Feb 24, 2023
1 parent 8ea6977 commit c572e68
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions runtime/src/snapshot_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1611,10 +1611,10 @@ fn create_snapshot_meta_files_for_unarchived_snapshot(unpack_dir: impl AsRef<Pat

// The unpacked dir has a single slot dir, which is the snapshot slot dir.
let slot_dir = fs::read_dir(&snapshots_dir)
.unwrap()
.map_err(|_| SnapshotError::NoSnapshotSlotDir(snapshots_dir.clone()))?
.find(|entry| entry.as_ref().unwrap().path().is_dir())
.unwrap()
.unwrap()
.ok_or_else(|| SnapshotError::NoSnapshotSlotDir(snapshots_dir.clone()))?
.map_err(|_| SnapshotError::NoSnapshotSlotDir(snapshots_dir.clone()))?
.path();

let version_file = unpack_dir.as_ref().join(SNAPSHOT_VERSION_FILENAME);
Expand Down

0 comments on commit c572e68

Please sign in to comment.