Skip to content

Commit

Permalink
Allow relative paths in new_file()/new_section() (#763)
Browse files Browse the repository at this point in the history
These functions expect that file_path can have base_path stripped from
it, but during reloading they can be given relative paths.  Maybe this
behaviour varies between the notify backends?

This fixes two zola serve panics on FreeBSD (poll backend).
  • Loading branch information
Freaky authored and Keats committed Aug 1, 2019
1 parent 7e61868 commit 0cd9e58
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions components/library/src/content/file_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ impl FileInfo {
let mut parent = file_path.parent().expect("Get parent of page").to_path_buf();
let name = path.file_stem().unwrap().to_string_lossy().to_string();
let mut components = find_content_components(
&file_path.strip_prefix(base_path).expect("Strip base path prefix for page"),
&file_path.strip_prefix(base_path).unwrap_or(&file_path),
);
let relative = if !components.is_empty() {
format!("{}/{}.md", components.join("/"), name)
Expand Down Expand Up @@ -92,7 +92,7 @@ impl FileInfo {
let parent = path.parent().expect("Get parent of section").to_path_buf();
let name = path.file_stem().unwrap().to_string_lossy().to_string();
let components = find_content_components(
&file_path.strip_prefix(base_path).expect("Strip base path prefix for section"),
&file_path.strip_prefix(base_path).unwrap_or(&file_path),
);
let relative = if !components.is_empty() {
format!("{}/{}.md", components.join("/"), name)
Expand Down

0 comments on commit 0cd9e58

Please sign in to comment.