diff --git a/backend/src/install/mod.rs b/backend/src/install/mod.rs index 48fc6b342..f4e99b5ae 100644 --- a/backend/src/install/mod.rs +++ b/backend/src/install/mod.rs @@ -1123,8 +1123,10 @@ pub async fn install_s9pk( if tokio::fs::metadata(&script_dir).await.is_err() { tokio::fs::create_dir_all(&script_dir).await?; } - let mut tar = tokio_tar::Archive::new(rdr.scripts().await?); - tar.unpack(script_dir).await?; + if let Some(hdl) = rdr.scripts().await? { + let mut tar = tokio_tar::Archive::new(hdl); + tar.unpack(script_dir).await?; + } Ok(()) }) diff --git a/backend/src/s9pk/builder.rs b/backend/src/s9pk/builder.rs index d144d2320..24e61673b 100644 --- a/backend/src/s9pk/builder.rs +++ b/backend/src/s9pk/builder.rs @@ -121,10 +121,10 @@ impl< std::io::copy(&mut self.scripts, &mut writer) .with_ctx(|_| (crate::ErrorKind::Filesystem, "Copying Scripts"))?; let new_pos = writer.inner_mut().stream_position()?; - header.table_of_contents.scripts = FileSection { + header.table_of_contents.scripts = Some(FileSection { position, length: new_pos - position, - }; + }); position = new_pos; // header diff --git a/backend/src/s9pk/header.rs b/backend/src/s9pk/header.rs index 1ac1f97cc..27b90bb2b 100644 --- a/backend/src/s9pk/header.rs +++ b/backend/src/s9pk/header.rs @@ -75,7 +75,7 @@ pub struct TableOfContents { pub icon: FileSection, pub docker_images: FileSection, pub assets: FileSection, - pub scripts: FileSection, + pub scripts: Option, } impl TableOfContents { pub fn serialize(&self, mut writer: W) -> std::io::Result<()> { @@ -95,7 +95,10 @@ impl TableOfContents { self.docker_images .serialize_entry("docker_images", &mut writer)?; self.assets.serialize_entry("assets", &mut writer)?; - self.scripts.serialize_entry("scripts", &mut writer)?; + match self.scripts { + None => FileSection::default().serialize_entry("scripts", &mut writer), + Some(a) => a.serialize_entry("scripts", &mut writer), + }; Ok(()) } pub async fn deserialize(mut reader: R) -> std::io::Result { @@ -134,7 +137,7 @@ impl TableOfContents { icon: from_table(&table, "icon")?, docker_images: from_table(&table, "docker_images")?, assets: from_table(&table, "assets")?, - scripts: from_table(&table, "scripts")?, + scripts: table.get("scripts".as_bytes()).cloned(), }) } } diff --git a/backend/src/s9pk/reader.rs b/backend/src/s9pk/reader.rs index 3270c9645..eb4043d27 100644 --- a/backend/src/s9pk/reader.rs +++ b/backend/src/s9pk/reader.rs @@ -306,7 +306,10 @@ impl S9pkReader { Ok(self.read_handle(self.toc.assets).await?) } - pub async fn scripts<'a>(&'a mut self) -> Result, Error> { - Ok(self.read_handle(self.toc.scripts).await?) + pub async fn scripts<'a>(&'a mut self) -> Result>, Error> { + Ok(match self.toc.scripts { + None => None, + Some(a) => Some(self.read_handle(a).await?), + }) } }