Create imported_assets directory with full path (#12022)

# Objective

- The file asset source currently creates the `imported_assets/Default`
directory with relative path, which leads to wrongly created directories
when the executable is run with a working directory different from the
project root.

## Solution

- Use the full path instead.
This commit is contained in:
Yutao Yuan 2024-02-22 05:59:59 +08:00 committed by GitHub
parent e64c8f8b7a
commit 11a3b77811
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -75,16 +75,15 @@ impl FileAssetWriter {
///
/// See `get_base_path` below.
pub fn new<P: AsRef<Path> + std::fmt::Debug>(path: P, create_root: bool) -> Self {
let root_path = get_base_path().join(path.as_ref());
if create_root {
if let Err(e) = std::fs::create_dir_all(&path) {
if let Err(e) = std::fs::create_dir_all(&root_path) {
error!(
"Failed to create root directory {:?} for file asset writer: {:?}",
path, e
root_path, e
);
}
}
Self {
root_path: get_base_path().join(path.as_ref()),
}
Self { root_path }
}
}