From 77ceccb079179dbea92ca702754438ea743031b9 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Mon, 17 May 2021 15:55:50 +0100 Subject: [PATCH] bundles: Print the bundle name after we have uploaded it Signed-off-by: Ian Jackson --- daemon/cmdlistener.rs | 6 +++--- src/bin/otter.rs | 7 ++++++- src/bundles.rs | 3 ++- src/commands.rs | 1 + src/mgmtchannel.rs | 2 +- 5 files changed, 13 insertions(+), 6 deletions(-) diff --git a/daemon/cmdlistener.rs b/daemon/cmdlistener.rs index 2e7498f3..e21d6a58 100644 --- a/daemon/cmdlistener.rs +++ b/daemon/cmdlistener.rs @@ -268,13 +268,13 @@ fn execute_and_respond(cs: &mut CommandStreamData, cmd: MgmtCommand, bulk_upload.inner_mut().set_timeout(Some(UPLOAD_TIMEOUT)); let uploaded = upload.bulk(bulk_upload, size, &hash, progress, &mut for_response)?; - { + let bundle = { let gref = Instance::lookup_by_name(&game, auth)?; let mut bundles = gref.lock_bundles(); let mut ig = gref.lock()?; - bundles.finish_upload(&mut ig, uploaded)?; + bundles.finish_upload(&mut ig, uploaded)? }; - Fine + MR::Bundle { bundle } } MC::ListBundles { game } => { let (ag, gref) = start_access_game(&game)?; diff --git a/src/bin/otter.rs b/src/bin/otter.rs index 1fd1b17c..67b2d2da 100644 --- a/src/bin/otter.rs +++ b/src/bin/otter.rs @@ -1401,7 +1401,12 @@ mod upload_bundle { progress: MgmtChannel::PROGRESS, }; let mut progress = termprogress::new(); - chan.cmd_withbulk(&cmd, &mut f, &mut io::sink(), &mut *progress)?; + let resp = chan.cmd_withbulk(&cmd, &mut f, &mut io::sink(), + &mut *progress)?; + if_let!{ MR::Bundle { bundle } = resp; + else throw!(anyhow!("unexpected {:?}", &resp)) }; + progress.clear(); + println!("{}", bundle); } inventory::submit!{Subcommand( diff --git a/src/bundles.rs b/src/bundles.rs index b695c4fa..789db9a9 100644 --- a/src/bundles.rs +++ b/src/bundles.rs @@ -925,7 +925,7 @@ impl Uploading { impl InstanceBundles { #[throws(MgmtError)] pub fn finish_upload(&mut self, ig: &mut Instance, - Uploaded { id, parsed }: Uploaded) { + Uploaded { id, parsed }: Uploaded) -> Id { let tmp = id.path_tmp(&ig.name); let install = id.path_(&ig.name); @@ -940,6 +940,7 @@ impl InstanceBundles { } ref x => panic!("unexpected {:?}", x), }; + id } } diff --git a/src/commands.rs b/src/commands.rs index 0c3f0645..317fb6a2 100644 --- a/src/commands.rs +++ b/src/commands.rs @@ -97,6 +97,7 @@ pub enum MgmtResponse { Libraries(Vec), LibraryItems(Vec), Bundles { bundles: MgmtBundleList }, + Bundle { bundle: bundles::Id }, } pub type MgmtBundleList = BTreeMap; diff --git a/src/mgmtchannel.rs b/src/mgmtchannel.rs index f205bd64..4baea5a6 100644 --- a/src/mgmtchannel.rs +++ b/src/mgmtchannel.rs @@ -113,7 +113,7 @@ impl MgmtChannel { match &resp { Progress(_) => panic!(), Fine | AccountsList{..} | GamesList{..} | - Libraries(_) | LibraryItems(_) | Bundles{..} => { }, + Libraries(_) | LibraryItems(_) | Bundles{..} | Bundle{..} => { }, AlterGame { error: None, .. } => { }, Error { error } => { Err(error.clone()).context( -- 2.30.2