chiark / gitweb /
bundles: Print the bundle name after we have uploaded it
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Mon, 17 May 2021 14:55:50 +0000 (15:55 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Mon, 17 May 2021 14:55:50 +0000 (15:55 +0100)
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
daemon/cmdlistener.rs
src/bin/otter.rs
src/bundles.rs
src/commands.rs
src/mgmtchannel.rs

index 2e7498f327cab96d9be926496e6684e5af08e8a0..e21d6a589b49838adfe29cdd8b0780bfa5aa9db4 100644 (file)
@@ -268,13 +268,13 @@ fn execute_and_respond<W>(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)?;
index 1fd1b17ccce6d87e3ba504ed9f7599196102d399..67b2d2da2d6bee0c432eacd38ce2bf979311f8e4 100644 (file)
@@ -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(
index b695c4fa0e623aedfb4be1894e9e917c55d8e76f..789db9a94db96eddef0d2813987dbd69a866e1d8 100644 (file)
@@ -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
   }
 }
 
index 0c3f0645ca8b98c54dc5640e79a82e3c474224ef..317fb6a22b6fc76f144ad7bf82c17ffffd5d6fca 100644 (file)
@@ -97,6 +97,7 @@ pub enum MgmtResponse {
   Libraries(Vec<LibraryEnquiryData>),
   LibraryItems(Vec<ItemEnquiryData>),
   Bundles { bundles: MgmtBundleList },
+  Bundle { bundle: bundles::Id },
 }
 
 pub type MgmtBundleList = BTreeMap<bundles::Id, bundles::State>;
index f205bd64bf3965a8f0c3a1b00cf44cb35ccdcd7c..4baea5a62c80be1c46a4995aed06fa6a20811949 100644 (file)
@@ -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(