chiark / gitweb /
bundles: Actually implement shape loading
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 15 May 2021 16:35:31 +0000 (17:35 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 15 May 2021 18:58:28 +0000 (19:58 +0100)
A small amount of glue!

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
src/bundles.rs
src/global.rs
src/shapelib.rs

index 5aa3362e18fb4286d8e375a608658e6350996900..ecc9319ff34e3ac5148fc9bda5ccfb32e310a2db 100644 (file)
@@ -703,7 +703,7 @@ fn make_usvg(za: &mut IndexedZip, progress_count: &mut usize,
 //---------- scanning/incorporating/uploading ----------
 
 #[throws(InternalError)]
-fn incorporate_bundle(ib: &mut InstanceBundles, _ig: &mut Instance,
+fn incorporate_bundle(ib: &mut InstanceBundles, ig: &mut Instance,
                  id: Id, parsed: Parsed) {
   let Parsed { meta, libs } = parsed;
 
@@ -718,7 +718,9 @@ fn incorporate_bundle(ib: &mut InstanceBundles, _ig: &mut Instance,
     })
   };
 
-  let _ = libs; // xxx actually incorporate
+  for lib in libs {
+    ig.local_libs.add(lib);
+  }
 
   let state = State::Loaded(Loaded { meta });
   *slot = Some(Note { kind: id.kind, state });
@@ -929,8 +931,7 @@ impl InstanceBundles {
     }
 
     // If we are in UNUSED, become BROKEN
-    // xxx: make shape libs and specs inaccessible to mgmt commands
-    let _ = ();
+    ig.local_libs.clear();
 
     (||{
       // If we are in BROKEN, become WRECKAGE
index 044ace922603e1d74a8dcf8518ea32f71ee26749..bc571fba88302ab871d939332bb89b0ee84a0dff 100644 (file)
@@ -58,6 +58,7 @@ pub struct Instance {
   pub links: Arc<LinksTable>,
   pub bundle_list: MgmtBundleList, // copy for easy access
   pub asset_url_key: AssetUrlKey,
+  pub local_libs: shapelib::Registry,
 }
 
 pub struct PlayerRecord {
@@ -350,6 +351,7 @@ impl Instance {
       links: default(),
       bundle_list: default(),
       asset_url_key: AssetUrlKey::new_random()?,
+      local_libs: default(),
     };
 
     let c = InstanceContainer {
@@ -507,6 +509,7 @@ impl Instance {
       links: default(),
       bundle_list: default(),
       asset_url_key: AssetUrlKey::Dummy,
+      local_libs: default(),
       iplayers: default(),
     }
   }
@@ -1184,6 +1187,7 @@ impl InstanceGuard<'_> {
       tokens_clients: default(),
       tokens_players: default(),
       bundle_list: default(), // set by load_game_bundles
+      local_libs: default(), // set by load_game_bundles
       asset_url_key,
     };
 
index 4d9eaec86b77a02ece11a96c401975c0f9aaab9c..ef1d39136fa0d6b6f087def1a718b7fd8908190b 100644 (file)
@@ -353,11 +353,15 @@ impl Registry {
       .entry(data.libname.clone()).or_default()
       .push(data);
   }
+
+  pub fn clear(&mut self) {
+    self.libs.clear()
+  }
 }
 
 pub struct AllRegistries<'ig> {
   global: RwLockReadGuard<'static, Option<Registry>>,
-  #[allow(dead_code)] ig: &'ig Instance,
+  ig: &'ig Instance,
 }
 pub struct AllRegistriesIterator<'i> {
   regs: &'i AllRegistries<'i>,
@@ -370,6 +374,7 @@ impl<'i> Iterator for AllRegistriesIterator<'i> {
     loop {
       let r = match self.count {
         0 => self.regs.global.as_ref(),
+        1 => Some(&self.regs.ig.local_libs),
         _ => return None,
       };
       self.count += 1;