From 4bf31df4fa1f99f8223d745ea396d3e0ed2bf886 Mon Sep 17 00:00:00 2001 From: Jeff Ching Date: Thu, 17 Sep 2020 12:52:02 -0700 Subject: [PATCH] fix: check whether or not we created destination directory (#81) `File#mkdirs()` will already throw security errors if it fails. We don't want to fail here as `File.#mkdirs()` will return `false` if the directory already exists - thus we should only log this case if the later file write fails. Fixes #47 --- src/main/java/com/google/cloud/DownloadComponentsMojo.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/google/cloud/DownloadComponentsMojo.java b/src/main/java/com/google/cloud/DownloadComponentsMojo.java index f571c05..05fcc66 100644 --- a/src/main/java/com/google/cloud/DownloadComponentsMojo.java +++ b/src/main/java/com/google/cloud/DownloadComponentsMojo.java @@ -113,7 +113,10 @@ private void executeInner() throws MojoExecutionException { } // Ensure that the output directory exists - destinationDir.mkdirs(); + if (!destinationDir.mkdirs()) { + getLog() + .info("Failed to create destination directory. Perhaps the directory already exists?"); + } // Update the cached manifest try {