Fix race condition with language folder creation
This commit is contained in:
parent
f45293ab25
commit
2e126b3a08
|
@ -246,16 +246,17 @@ impl Site {
|
||||||
if !self.library.contains_section(&index_path) {
|
if !self.library.contains_section(&index_path) {
|
||||||
let mut index_section = Section::default();
|
let mut index_section = Section::default();
|
||||||
index_section.file.parent = self.content_path.clone();
|
index_section.file.parent = self.content_path.clone();
|
||||||
index_section.file.name = "_index".to_string();
|
|
||||||
index_section.file.filename =
|
index_section.file.filename =
|
||||||
index_path.file_name().unwrap().to_string_lossy().to_string();
|
index_path.file_name().unwrap().to_string_lossy().to_string();
|
||||||
if let Some(ref l) = lang {
|
if let Some(ref l) = lang {
|
||||||
|
index_section.file.name = format!("_index.{}", l);
|
||||||
index_section.permalink = self.config.make_permalink(l);
|
index_section.permalink = self.config.make_permalink(l);
|
||||||
let filename = format!("_index.{}.md", l);
|
let filename = format!("_index.{}.md", l);
|
||||||
index_section.file.path = self.content_path.join(&filename);
|
index_section.file.path = self.content_path.join(&filename);
|
||||||
index_section.file.relative = filename;
|
index_section.file.relative = filename;
|
||||||
index_section.lang = Some(l.clone());
|
index_section.lang = index_section.file.find_language(&self.config)?;
|
||||||
} else {
|
} else {
|
||||||
|
index_section.file.name = "_index".to_string();
|
||||||
index_section.permalink = self.config.make_permalink("");
|
index_section.permalink = self.config.make_permalink("");
|
||||||
index_section.file.path = self.content_path.join("_index.md");
|
index_section.file.path = self.content_path.join("_index.md");
|
||||||
index_section.file.relative = "_index.md".to_string();
|
index_section.file.relative = "_index.md".to_string();
|
||||||
|
@ -323,7 +324,8 @@ impl Site {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Adds global fns that are to be available to shortcodes while rendering markdown
|
/// Adds global fns that are to be available to shortcodes while
|
||||||
|
/// markdown
|
||||||
pub fn register_early_global_fns(&mut self) {
|
pub fn register_early_global_fns(&mut self) {
|
||||||
self.tera.register_function(
|
self.tera.register_function(
|
||||||
"get_url",
|
"get_url",
|
||||||
|
@ -907,6 +909,9 @@ impl Site {
|
||||||
|
|
||||||
if let Some(ref lang) = section.lang {
|
if let Some(ref lang) = section.lang {
|
||||||
output_path.push(lang);
|
output_path.push(lang);
|
||||||
|
if !output_path.exists() {
|
||||||
|
create_directory(&output_path)?;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for component in §ion.file.components {
|
for component in §ion.file.components {
|
||||||
|
|
|
@ -19,7 +19,7 @@ pub fn is_path_in_directory(parent: &Path, path: &Path) -> Result<bool> {
|
||||||
|
|
||||||
/// Create a file with the content given
|
/// Create a file with the content given
|
||||||
pub fn create_file(path: &Path, content: &str) -> Result<()> {
|
pub fn create_file(path: &Path, content: &str) -> Result<()> {
|
||||||
let mut file = File::create(&path)?;
|
let mut file = File::create(&path).chain_err(|| format!("Failed to create {:?}", path))?;
|
||||||
file.write_all(content.as_bytes())?;
|
file.write_all(content.as_bytes())?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue