Skip to content

Commit

Permalink
storage: Change to return Result
Browse files Browse the repository at this point in the history
Prep for adding more falliable initialization here.

Signed-off-by: Colin Walters <[email protected]>
  • Loading branch information
cgwalters committed Jul 25, 2024
1 parent 3b9cd28 commit fe6407a
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@ pub(crate) async fn get_locked_sysroot() -> Result<ostree_ext::sysroot::SysrootL
#[context("Initializing storage")]
pub(crate) async fn get_storage() -> Result<crate::store::Storage> {
let sysroot = get_locked_sysroot().await?;
Ok(crate::store::Storage::new(sysroot))
crate::store::Storage::new(sysroot)
}

#[context("Querying root privilege")]
Expand Down
2 changes: 1 addition & 1 deletion lib/src/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -610,7 +610,7 @@ async fn initialize_ostree_root(state: &State, root_setup: &RootSetup) -> Result
let sysroot = ostree::Sysroot::new(Some(&gio::File::for_path(rootfs)));
sysroot.load(cancellable)?;
let sysroot = SysrootLock::new_from_sysroot(&sysroot).await?;
Ok(Storage::new(sysroot))
Storage::new(sysroot)
}

#[context("Creating ostree deployment")]
Expand Down
4 changes: 2 additions & 2 deletions lib/src/store/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ impl Deref for Storage {
}

impl Storage {
pub fn new(sysroot: SysrootLock) -> Self {
pub fn new(sysroot: SysrootLock) -> Result<Self> {
let store = match env::var("BOOTC_STORAGE") {
Ok(val) => crate::spec::Store::from_str(&val, true).unwrap_or_else(|_| {
let default = crate::spec::Store::default();
Expand All @@ -60,7 +60,7 @@ impl Storage {

let store = load(store);

Self { sysroot, store }
Ok(Self { sysroot, store })
}
}

Expand Down

0 comments on commit fe6407a

Please sign in to comment.