From 41a693a528b707f27dc27849cd41aaefc6c063c8 Mon Sep 17 00:00:00 2001 From: Vincent Prouillet Date: Fri, 16 Nov 2018 16:59:06 +0100 Subject: [PATCH] Ignore rename of non md files --- components/rebuild/src/lib.rs | 7 +++++++ components/rebuild/tests/rebuild.rs | 11 +++++++++++ test_site/content/posts/with-assets/index.md | 2 +- test_site/content/posts/with-assets/zola.png | Bin 0 -> 3953 bytes 4 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 test_site/content/posts/with-assets/zola.png diff --git a/components/rebuild/src/lib.rs b/components/rebuild/src/lib.rs index 48fbe6fc..7b6d3a16 100644 --- a/components/rebuild/src/lib.rs +++ b/components/rebuild/src/lib.rs @@ -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 diff --git a/components/rebuild/tests/rebuild.rs b/components/rebuild/tests/rebuild.rs index 275273e0..4d743ab9 100644 --- a/components/rebuild/tests/rebuild.rs +++ b/components/rebuild/tests/rebuild.rs @@ -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()); +} diff --git a/test_site/content/posts/with-assets/index.md b/test_site/content/posts/with-assets/index.md index b182f9a3..383ad8ab 100644 --- a/test_site/content/posts/with-assets/index.md +++ b/test_site/content/posts/with-assets/index.md @@ -4,4 +4,4 @@ description = "hey there" date = 2015-03-01 +++ -Hello world +Hello world [here](with.js) diff --git a/test_site/content/posts/with-assets/zola.png b/test_site/content/posts/with-assets/zola.png new file mode 100644 index 0000000000000000000000000000000000000000..1eb41f9ca2b35fbffa1d5933441fd0506fff6002 GIT binary patch literal 3953 zcmc&%`Crmm_x~U%W-5XUGv!K)+ZdzixS(lo zmZmi6j854mhFX|uX1L^3g1e3xXqaRO-;49SUf=IO@O_@2fWy7#eeXH%^FHS?_V{^f zsI6CnAV|Y&H(@UX!N6A-q^bfw4#w9+K@ifxi?AbzTsrq5?LyC@A$NYM?$E%8*d!D& zaNllyl&42kyjA$LyT;h*&hcLZVyhCF@fMG2rdw-v)jr=`>wD&Tbcs#So6+4D540Y! zn!VU8WcL_3op*{@Y7+977Qa$j>X*94lttT>`@QH2$SbJyip-ItRuFP z5EPj<-mZ~uY#JNGq9>xb)h+ZcZ6-WRzHXO}avC9`fG$SAzICo6aimwfVuIe0j=g9B z^UbIGYBRGSy^WQfcq~?%u*qxGma5ANSUm6h=)hcJFsTyi|cVDv~^t!aAH<}_D$*bnJP`<`X z_zC_TxY?06Jf5As{oqH*=Y@qo!5UGsvof-r9?}rO7@EJs(ll_=VPE13U^*r{&#GIy z$Rb}BagrDGooQI?#*I6X`VNPaq$w#WB}^ua|1v=Y<{IkKS#2#D$~|~#3(*#b>-i`F4$5a{W<<^IN``JGOP?MKOB8#F_8->p%?SYZ zNZVPBZ7#BB=P+%_YTtvsL5)$};@1^BqqsM&U3=+IO%p+CwM)Zkz!`~j>cNPL#Lr|6 zvRrGu^^u&J`IeP0??h$pYQTBIm!YG_Gcwpi^Fn@0*arJpb-v{-fM8=8TxW~VAoX*y z5dgy)V03gaHxdiw-S+$(p-wyiVCY#Lm>y}%>n@=3+3BeRAxAk&YK~xK&Z5zR^|9B+ z5m0`h+uH&al6U4w<6t^W=7)tc<$rkFOM9{)}t`YS_l9a`Q zBQybq2{65#?!5^>7YD=gggVy1(D!ia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