Skip to content

Commit

Permalink
Don't choke on directories
Browse files Browse the repository at this point in the history
  • Loading branch information
onigoetz committed Feb 8, 2024
1 parent 9c938a8 commit c1a107a
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,11 @@ private static void copyDirectory(String sourceDirectoryLocation, String destina
for (Path source : (Iterable<Path>) walk::iterator) {
Path destination = Paths.get(destinationDirectoryLocation, source.toString()
.substring(sourceDirectoryLocation.length()));
Files.copy(source, destination, StandardCopyOption.REPLACE_EXISTING);

// Don't try to overwrite directories that already exist
if (!(Files.isDirectory(source) && Files.exists(destination))) {
Files.copy(source, destination, StandardCopyOption.REPLACE_EXISTING);
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,11 @@ private static void copyDirectory(String sourceDirectoryLocation, String destina
for (Path source : (Iterable<Path>) walk::iterator) {
Path destination = Paths.get(destinationDirectoryLocation, source.toString()
.substring(sourceDirectoryLocation.length()));
Files.copy(source, destination, StandardCopyOption.REPLACE_EXISTING);

// Don't try to overwrite directories that already exist
if (!(Files.isDirectory(source) && Files.exists(destination))) {
Files.copy(source, destination, StandardCopyOption.REPLACE_EXISTING);
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,11 @@ private static void copyDirectory(String sourceDirectoryLocation, String destina
for (Path source : (Iterable<Path>) walk::iterator) {
Path destination = Paths.get(destinationDirectoryLocation, source.toString()
.substring(sourceDirectoryLocation.length()));
Files.copy(source, destination, StandardCopyOption.REPLACE_EXISTING);

// Don't try to overwrite directories that already exist
if (!(Files.isDirectory(source) && Files.exists(destination))) {
Files.copy(source, destination, StandardCopyOption.REPLACE_EXISTING);
}
}
}
}
Expand Down

0 comments on commit c1a107a

Please sign in to comment.