Ignore rename of non md files
This commit is contained in:
parent
c913f341c3
commit
41a693a528
|
@ -262,6 +262,13 @@ pub fn after_content_rename(site: &mut Site, old: &Path, new: &Path) -> Result<(
|
||||||
return site.build();
|
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
|
// 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" {
|
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
|
// We aren't entirely sure where the original thing was so just try to delete whatever was
|
||||||
|
|
|
@ -223,3 +223,14 @@ fn can_rebuild_after_renaming_section_folder() {
|
||||||
|
|
||||||
assert!(file_contains!(site_path, "public/new-posts/simple/index.html", "simple"));
|
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());
|
||||||
|
}
|
||||||
|
|
|
@ -4,4 +4,4 @@ description = "hey there"
|
||||||
date = 2015-03-01
|
date = 2015-03-01
|
||||||
+++
|
+++
|
||||||
|
|
||||||
Hello world
|
Hello world [here](with.js)
|
||||||
|
|
BIN
test_site/content/posts/with-assets/zola.png
Normal file
BIN
test_site/content/posts/with-assets/zola.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.9 KiB |
Loading…
Reference in a new issue