chiark / gitweb /
bundles: Restructure zip load_spec_to_read
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Mon, 7 Jun 2021 17:18:59 +0000 (18:18 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Tue, 8 Jun 2021 00:15:26 +0000 (01:15 +0100)
Move more into the Zip branch to simplify the structure.

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

index 0afce3235e6cbc87e61af874ce698e52a448f047..9fd4477a1a541343d26020aedd184569108af1da 100644 (file)
@@ -906,18 +906,21 @@ pub fn load_spec_to_read(ig: &Instance, spec_name: &str) -> String {
   let spec_leaf = format!("{}.game.toml", spec_name);
 
   if let Some((id, index)) = ig.bundle_specs.get(&UniCase::from(spec_name)) {
-    let fpath = id.path_(&ig.name);
-    let f = File::open(&fpath)
-      .with_context(|| fpath.clone()).context("reopen bundle")
-      .map_err(IE::from)?;
     match id.kind {
       Kind::Zip => {
+
+        let fpath = id.path_(&ig.name);
+        let f = File::open(&fpath)
+          .with_context(|| fpath.clone()).context("reopen bundle")
+          .map_err(IE::from)?;
+
         let mut za = ZipArchive::new(BufReader::new(f)).map_err(
           |e| LE::BadBundle(format!("re-examine zipfile: {}", e)))?;
         let mut f = za.i(*index).map_err(
           |e| LE::BadBundle(format!("re-find zipfile member: {}", e)))?;
         return read_from_read(&mut f, &mut |e|{
           LE::BadBundle(format!("read zipfile member: {}", e))}.into())?;
+
       }
     }
   }