diff --git a/source/dub/generators/generator.d b/source/dub/generators/generator.d index 8010988ef..68060a2c9 100644 --- a/source/dub/generators/generator.d +++ b/source/dub/generators/generator.d @@ -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); } } } diff --git a/source/dub/internal/vibecompat/core/file.d b/source/dub/internal/vibecompat/core/file.d index 5a806a3db..bfa9caccf 100644 --- a/source/dub/internal/vibecompat/core/file.d +++ b/source/dub/internal/vibecompat/core/file.d @@ -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