Skip to content

Commit

Permalink
Merge pull request #191 from cobalt-org/fix_wrong_relative_path
Browse files Browse the repository at this point in the history
Fix wrong relative path generation
  • Loading branch information
tak1n committed Feb 27, 2017
2 parents 536ea4f + 629fbc6 commit 3309acc
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 3309acc

Please sign in to comment.