Skip to content

Commit

Permalink
fix for not being able to copy files inside a folder
Browse files Browse the repository at this point in the history
  • Loading branch information
LucioFranco committed Mar 15, 2016
1 parent 0e12302 commit 02f866c
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/cobalt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ pub fn build(config: &Config) -> Result<()> {
let dest = dest.as_path();

let template_extensions: Vec<&OsStr> = config.template_extensions
.iter()
.map(OsStr::new)
.collect();
.iter()
.map(OsStr::new)
.collect();

let layouts_path = source.join(&config.layouts);
let posts_path = source.join(&config.posts);
Expand Down Expand Up @@ -144,6 +144,11 @@ pub fn build(config: &Config) -> Result<()> {
try!(fs::create_dir_all(&dest.join(relative)));
debug!("Created new directory {:?}", dest.join(relative));
} else {
let parent_folder_path = dest.clone()
.join(Path::new(relative).parent().unwrap());

try!(fs::create_dir_all(&parent_folder_path));

try!(fs::copy(entry.path(), &dest.join(relative))
.map_err(|_| format!("Could not copy {:?}", entry.path())));
debug!("Copied {:?} to {:?}", entry.path(), dest.join(relative));
Expand Down

0 comments on commit 02f866c

Please sign in to comment.