chiark / gitweb /
bundles: Move and centralise update()
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Mon, 3 May 2021 16:24:38 +0000 (17:24 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Mon, 3 May 2021 16:58:58 +0000 (17:58 +0100)
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
src/bundles.rs

index 703a25fddf48ee5a1ab2eb266ec456d43760ae4f..bf066c9e73c0e5f8d068f227ec85f8174f46b0d4 100644 (file)
@@ -183,7 +183,6 @@ fn load_bundle(ib: &mut InstanceBundles, ig: &mut Instance,
   };
 
   *slot = Some(Note { kind: id.kind, state });
-  ib.update_mgmt_list(ig);
 }
 
 #[throws(IncorporateError)]
@@ -212,7 +211,7 @@ impl InstanceBundles {
     })
   }
 
-  fn update_mgmt_list(&self, ig: &mut Instance) {
+  fn updated(&self, ig: &mut Instance) {
     ig.bundle_list = self.iter().map(|(id, state)| {
       (id, state.clone())
     }).collect()
@@ -242,7 +241,7 @@ impl InstanceBundles {
       }
     }
     debug!("loaded bundles {} {:?}", &ig.name, ib);
-    ib.update_mgmt_list(ig);
+    ib.updated(ig);
     ib
   }
 
@@ -276,7 +275,7 @@ impl InstanceBundles {
     let file = BufWriter::new(file);
     let file = DigestWrite::new(file);
     let instance = ig.name.clone();
-    self.update_mgmt_list(ig);
+    self.updated(ig);
     Uploading { file, instance, id }
   }
 }
@@ -304,6 +303,7 @@ impl InstanceBundles {
       .with_context(|| tmp.clone()).context("flush").map_err(IE::from)?;
     if hash.as_slice() != &expected.0[..] { throw!(ME::UploadCorrupted) }
     load_bundle(self, ig, id, &tmp)?;
+    self.updated(ig);
     match self.bundles.get(usize::from(id.index)) {
       Some(Some(Note { state: State::Loaded(..), .. })) => {
         fs::rename(&tmp, &install)