Skip to content

Commit

Permalink
Fix wrong relative path generation, this fixes #190
Browse files Browse the repository at this point in the history
  • Loading branch information
tak1n committed Feb 25, 2017
1 parent 536ea4f commit 629fbc6
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions src/cobalt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,10 +183,14 @@ pub fn build(config: &Config) -> Result<()> {
.to_str()
.ok_or(format!("Cannot convert pathname {:?} to UTF-8", entry.path())));

let relative = try!(entry_path.split(source_str)
.last()
.map(|s| s.trim_left_matches("/"))
.ok_or("Empty path"));
let relative = if source_str == "." {
entry_path
} else {
try!(entry_path.split(source_str)
.last()
.map(|s| s.trim_left_matches("/"))
.ok_or("Empty path"))
};

if try!(entry.metadata()).is_dir() {
try!(fs::create_dir_all(&dest.join(relative)));
Expand All @@ -196,8 +200,12 @@ pub fn build(config: &Config) -> Result<()> {
try!(fs::create_dir_all(&dest.join(parent)));
}

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

0 comments on commit 629fbc6

Please sign in to comment.