Ignore rename of non md files

This commit is contained in:
Vincent Prouillet 2018-11-16 16:59:06 +01:00
parent c913f341c3
commit 41a693a528
4 changed files with 19 additions and 1 deletions

View file

@ -262,6 +262,13 @@ pub fn after_content_rename(site: &mut Site, old: &Path, new: &Path) -> Result<(
return site.build();
}
// We ignore renames on non-markdown files for now
if let Some(ext) = new_path.extension() {
if ext != "md" {
return Ok(());
}
}
// Renaming a file to _index.md, let the section editing do something and hope for the best
if new_path.file_name().unwrap() == "_index.md" {
// We aren't entirely sure where the original thing was so just try to delete whatever was

View file

@ -223,3 +223,14 @@ fn can_rebuild_after_renaming_section_folder() {
assert!(file_contains!(site_path, "public/new-posts/simple/index.html", "simple"));
}
#[test]
fn can_rebuild_after_renaming_non_md_asset_in_colocated_folder() {
let tmp_dir = tempdir().expect("create temp dir");
let (site_path, mut site) = load_and_build_site!(tmp_dir);
let (old_path, new_path) = rename!(site_path, "content/posts/with-assets/zola.png", "gutenberg.png");
// Testing that we don't try to load some images as markdown or something
let res = after_content_rename(&mut site, &old_path, &new_path);
assert!(res.is_ok());
}

View file

@ -4,4 +4,4 @@ description = "hey there"
date = 2015-03-01
+++
Hello world
Hello world [here](with.js)

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB