From: Ian Jackson Date: Mon, 10 May 2021 18:02:05 +0000 (+0100) Subject: bundles: Plumb for_progress through to processing X-Git-Tag: otter-0.6.0~352 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=7e95d590abaffd1f253bc567ef94d973159601cf;p=otter.git bundles: Plumb for_progress through to processing Signed-off-by: Ian Jackson --- diff --git a/daemon/cmdlistener.rs b/daemon/cmdlistener.rs index 9efcf7b7..d5c16e26 100644 --- a/daemon/cmdlistener.rs +++ b/daemon/cmdlistener.rs @@ -81,7 +81,7 @@ fn execute_and_respond(cs: &mut CommandStreamData, cmd: MgmtCommand, where R: Read, W: Write { let mut bulk_download: Option> = None; - let for_response = for_response + let mut for_response = for_response .write_withbulk().context("start to respond")?; let mut cmd_s = log_enabled!(log::Level::Info) @@ -233,7 +233,7 @@ fn execute_and_respond(cs: &mut CommandStreamData, cmd: MgmtCommand, let upload = bundles.start_upload(ig, kind)?; (upload, auth) }; - let uploaded = upload.bulk(&mut bulk_upload, &hash)?; + let uploaded = upload.bulk(&mut bulk_upload, &hash, &mut for_response)?; { let gref = Instance::lookup_by_name(&game, auth)?; let mut bundles = gref.lock_bundles(); diff --git a/src/bundles.rs b/src/bundles.rs index fab48e7a..a69b2d05 100644 --- a/src/bundles.rs +++ b/src/bundles.rs @@ -3,6 +3,7 @@ // There is NO WARRANTY. use crate::prelude::*; +use crate::packetframe::ResponseWriter; //---------- public types ---------- @@ -393,7 +394,10 @@ where EH: BundleParseError, } #[throws(LE)] -fn process_bundle(id: Id, instance: &InstanceName) { +fn process_bundle(id: Id, instance: &InstanceName, + _for_progress: &ResponseWriter) +where W: Write +{ let dir = id.path_dir(instance); fs::create_dir(&dir) .with_context(|| dir.clone()).context("mkdir").map_err(IE::from)?; @@ -540,8 +544,9 @@ impl InstanceBundles { impl Uploading { #[throws(MgmtError)] - pub fn bulk(self, data: &mut R, expected: &Hash) -> Uploaded - where R: Read + pub fn bulk(self, data: &mut R, expected: &Hash, + for_progress: &mut ResponseWriter) -> Uploaded + where R: Read, W: Write { let Uploading { id, mut file, instance } = self; let tmp = id.path_tmp(&instance); @@ -561,7 +566,7 @@ impl Uploading { let parsed = parse_bundle::(id, &mut file, &tmp)?; - process_bundle(id, &*instance)?; + process_bundle(id, &*instance, for_progress)?; Uploaded { id, parsed } }