commit 35d90d2d9b6db3ff47e1df65df770f8f30367474
parent 1c10b059cf642322e184e6281185a2428e05f5b8
Author: Gavin Peacock <gpeacock@adobe.com>
Date: Thu, 16 Mar 2023 09:24:00 -0700
Adds base_path_take to ResourceStore (#205)
Allows for memory writes to file based manifests
Fixes thumbnail write when reading from file based manifests.
Diffstat:
2 files changed, 10 insertions(+), 0 deletions(-)
diff --git a/sdk/src/manifest.rs b/sdk/src/manifest.rs
@@ -629,7 +629,12 @@ impl Manifest {
if self.thumbnail().is_none() {
#[cfg(feature = "add_thumbnails")]
if let Ok((format, image)) = crate::utils::thumbnail::make_thumbnail(path.as_ref()) {
+ // Do not write this as a file when reading from files
+ let base_path = self.resources_mut().take_base_path();
self.set_thumbnail(format, image)?;
+ if let Some(path) = base_path {
+ self.resources_mut().set_base_path(path)
+ }
}
}
Ok(())
diff --git a/sdk/src/resource_store.rs b/sdk/src/resource_store.rs
@@ -69,6 +69,11 @@ impl ResourceStore {
self.base_path = Some(base_path.into());
}
+ #[cfg(feature = "file_io")]
+ pub fn take_base_path(&mut self) -> Option<PathBuf> {
+ self.base_path.take()
+ }
+
/// generate a unique id for a given content type (adds a file extension)
pub fn id_from(&self, key: &str, format: &str) -> String {
let ext = match format {