Skip to content

Commit

Permalink
Merge pull request #1096 from baranowb/UNDERTOW-1468
Browse files Browse the repository at this point in the history
[UNDERTOW-1468] - File upload form -replace existing instead of break…
  • Loading branch information
ropalka authored Apr 13, 2021
2 parents 20f351c + a11249a commit b5a0132
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import java.nio.file.Files;
import java.nio.file.NoSuchFileException;
import java.nio.file.Path;
import java.nio.file.StandardCopyOption;
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.Iterator;
Expand Down Expand Up @@ -262,15 +263,15 @@ public void delete() throws IOException {
public void write(Path target) throws IOException {
if (file != null) {
try {
Files.move(file, target);
Files.move(file, target, StandardCopyOption.REPLACE_EXISTING);
return;
} catch (IOException e) {
// ignore and let the Files.copy, outside
// this if block, take over and attempt to copy it
}
}
try (InputStream is = getInputStream()) {
Files.copy(is, target);
Files.copy(is, target, StandardCopyOption.REPLACE_EXISTING);
}
}
}
Expand Down

0 comments on commit b5a0132

Please sign in to comment.