Skip to content

Commit

Permalink
Fix trying to copy copyFiles where source==destination.
Browse files Browse the repository at this point in the history
  • Loading branch information
s-ludwig committed Aug 25, 2014
1 parent 8cdd917 commit c747339
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 5 additions & 1 deletion source/dub/generators/generator.d
Original file line number Diff line number Diff line change
Expand Up @@ -283,10 +283,14 @@ private void finalizeGeneration(string pack, in BuildSettings buildsettings, Pat
auto src = Path(f);
if (!src.absolute) src = pack_path ~ src;
auto dst = target_path ~ Path(f).head;
if (src == dst) {
logDiagnostic("Skipping copy of %s (same source and destination)", f);
continue;
}
logDiagnostic(" %s to %s", src.toNativeString(), dst.toNativeString());
try {
copyFile(src, dst, true);
} catch logWarn("Failed to copy to %s", dst.toNativeString());
} catch(Exception e) logWarn("Failed to copy to %s: %s", dst.toNativeString(), e.msg);
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions source/dub/internal/vibecompat/core/file.d
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ void moveFile(string from, string to)
*/
void copyFile(Path from, Path to, bool overwrite = false)
{
enforce(existsFile(from), "Source file doesn not exist.");

if (existsFile(to)) {
enforce(overwrite, "Destination file already exists.");
// remove file before copy to allow "overwriting" files that are in
Expand Down

0 comments on commit c747339

Please sign in to comment.