Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stop automatically generating meta files for assets while using asset processing. #17216

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions crates/bevy_asset/src/processor/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -797,12 +797,6 @@ impl AssetProcessor {
}
};
let meta_bytes = meta.serialize();
// write meta to source location if it doesn't already exist
source
.writer()?
.write_meta_bytes(path, &meta_bytes)
.await
.map_err(writer_err)?;
(meta, meta_bytes, processor)
}
Err(err) => {
Expand Down
37 changes: 36 additions & 1 deletion crates/bevy_asset/src/server/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ use crate::{
folder::LoadedFolder,
io::{
AssetReaderError, AssetSource, AssetSourceEvent, AssetSourceId, AssetSources,
ErasedAssetReader, MissingAssetSourceError, MissingProcessedAssetReaderError, Reader,
AssetWriterError, ErasedAssetReader, MissingAssetSourceError, MissingAssetWriterError,
MissingProcessedAssetReaderError, Reader,
},
loader::{AssetLoader, ErasedAssetLoader, LoadContext, LoadedAsset},
meta::{
Expand Down Expand Up @@ -1466,6 +1467,28 @@ impl AssetServer {
}
}
}

/// Writes the default meta file for the provided `path`.
///
/// Note if there is already a meta file for `path`, it will be overwritten.
pub async fn write_default_meta_file_for_path(
&self,
path: impl Into<AssetPath<'_>>,
) -> Result<(), WriteDefaultMetaError> {
let path = path.into();
let loader = self.get_path_asset_loader(&path).await?;

let meta = loader.default_meta();
let serialized_meta = meta.serialize();

let source = self.get_source(path.source())?;
let writer = source.writer()?;
writer
.write_meta_bytes(path.path(), &serialized_meta)
.await?;

Ok(())
}
}

/// A system that manages internal [`AssetServer`] events, such as finalizing asset loads.
Expand Down Expand Up @@ -1860,3 +1883,15 @@ pub enum WaitForAssetError {
#[error(transparent)]
DependencyFailed(Arc<AssetLoadError>),
}

#[derive(Error, Debug)]
pub enum WriteDefaultMetaError {
#[error(transparent)]
MissingAssetLoader(#[from] MissingAssetLoaderForExtensionError),
#[error(transparent)]
MissingAssetSource(#[from] MissingAssetSourceError),
#[error(transparent)]
MissingAssetWriter(#[from] MissingAssetWriterError),
#[error("Failed to write default asset meta file: {0}")]
FailedToWriteMeta(#[from] AssetWriterError),
}
13 changes: 0 additions & 13 deletions examples/asset/processing/assets/d.cool.ron.meta

This file was deleted.

13 changes: 0 additions & 13 deletions examples/asset/processing/assets/foo/b.cool.ron.meta

This file was deleted.

13 changes: 0 additions & 13 deletions examples/asset/processing/assets/foo/c.cool.ron.meta

This file was deleted.

Loading