fix dir creation bugs
This commit is contained in:
parent
88ba7a6dd3
commit
5369304516
@ -36,6 +36,10 @@ impl MetadataFile {
|
|||||||
let mut path_tmp = path.to_path_buf();
|
let mut path_tmp = path.to_path_buf();
|
||||||
assert!(path_tmp.set_extension("js.tmp"));
|
assert!(path_tmp.set_extension("js.tmp"));
|
||||||
|
|
||||||
|
let mut base = path.to_path_buf();
|
||||||
|
base.pop();
|
||||||
|
fs::create_dir_all(&base)?;
|
||||||
|
|
||||||
let mut file = fs::File::create(&path_tmp)?;
|
let mut file = fs::File::create(&path_tmp)?;
|
||||||
serde_json::to_writer(&mut file, &self)?;
|
serde_json::to_writer(&mut file, &self)?;
|
||||||
file.flush()?;
|
file.flush()?;
|
||||||
|
@ -43,9 +43,14 @@ pub struct DataStore {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl DataStore {
|
impl DataStore {
|
||||||
fn texture_file_path(&self, sha: &Sha256) -> PathBuf {
|
fn texture_base_path(&self) -> PathBuf {
|
||||||
let mut path = self.base_dir.clone();
|
let mut path = self.base_dir.clone();
|
||||||
path.push("textures");
|
path.push("textures");
|
||||||
|
path
|
||||||
|
}
|
||||||
|
|
||||||
|
fn texture_file_path(&self, sha: &Sha256) -> PathBuf {
|
||||||
|
let mut path = self.texture_base_path();
|
||||||
path.push(sha.as_hex_string());
|
path.push(sha.as_hex_string());
|
||||||
path
|
path
|
||||||
}
|
}
|
||||||
@ -156,9 +161,9 @@ impl DataStore {
|
|||||||
use std::io::Write;
|
use std::io::Write;
|
||||||
|
|
||||||
let hash = crate::model::Sha256::from_data(data);
|
let hash = crate::model::Sha256::from_data(data);
|
||||||
let file_path = self.texture_file_path(&hash);
|
|
||||||
|
|
||||||
fs::create_dir_all(&file_path)?;
|
fs::create_dir_all(&self.texture_base_path())?;
|
||||||
|
let file_path = self.texture_file_path(&hash);
|
||||||
|
|
||||||
let mut file = fs::File::create(&file_path)?;
|
let mut file = fs::File::create(&file_path)?;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user