From e3ad92837c5439a1be736086e5e4597185f0a653 Mon Sep 17 00:00:00 2001 From: Tom Kirchner Date: Mon, 13 Jul 2020 16:00:48 -0700 Subject: [PATCH] updata add-update: don't create manifest, require 'init' first Automatically creating a manifest during `add-update` can be problematic if you thought the manifest path did exist. You may create an empty repo instead of adding to one as intended. This change requires "init" to be run first, so you're showing your intention to create a new repo. --- sources/updater/update_metadata/src/error.rs | 2 +- sources/updater/updog/src/bin/updata.rs | 6 +----- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/sources/updater/update_metadata/src/error.rs b/sources/updater/update_metadata/src/error.rs index 1225b0a0279..b486fe0f869 100644 --- a/sources/updater/update_metadata/src/error.rs +++ b/sources/updater/update_metadata/src/error.rs @@ -71,7 +71,7 @@ pub enum Error { backtrace: Backtrace, }, - #[snafu(display("Failed to read manifest file {}: {}", path.display(), source))] + #[snafu(display("Failed to read manifest file '{}' - do you need to `updata init`? ({})", path.display(), source))] ManifestRead { path: PathBuf, source: std::io::Error, diff --git a/sources/updater/updog/src/bin/updata.rs b/sources/updater/updog/src/bin/updata.rs index b1c0bad3c11..4d549983df2 100644 --- a/sources/updater/updog/src/bin/updata.rs +++ b/sources/updater/updog/src/bin/updata.rs @@ -59,11 +59,7 @@ struct AddUpdateArgs { impl AddUpdateArgs { fn run(self) -> Result<()> { - let mut manifest: Manifest = match update_metadata::load_file(&self.file) { - Ok(m) => m, - _ => Manifest::default(), // TODO only if EEXIST - }; - + let mut manifest: Manifest = update_metadata::load_file(&self.file)?; manifest.add_update( self.image_version, self.max_version,