Skip to content

Commit

Permalink
Check if folder exists before attempting to create it
Browse files Browse the repository at this point in the history
  • Loading branch information
RetGal committed Jun 30, 2024
1 parent 0c41858 commit 7b5e578
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public static NetworkClipboardFilesHelper unmarshall(ObjectInputStream in, Netwo
FileMetaData meta = helper.getFileMetadatas().get(position);

long fileSize = meta.getFileSize();
Log.debug(format("FileSize/left: %s/%s", fileSize, helper.getFileBytesLeft()));
Log.debug("%s", () -> format("FileSize/left: %s/%s", fileSize, helper.getFileBytesLeft()));

byte[] buffer = new byte[min(toIntExact(helper.getFileBytesLeft()), MAX_READ_BUFFER_CAPACITY)];
BufferedInputStream bis = new BufferedInputStream(in);
Expand Down Expand Up @@ -82,7 +82,7 @@ private static long getRemainingTotalFilesSize(NetworkClipboardFilesHelper helpe

private static void writeToTempFile(byte[] buffer, int length, String tempFileName, boolean append) throws IOException {
final Path parent = Paths.get(tempFileName).getParent();
if (parent != null) {
if (parent != null && !Files.exists(parent)) {
final boolean created = parent.toFile().mkdirs();
if (!created) {
Log.error("Could not create parent directories for " + tempFileName);
Expand Down

0 comments on commit 7b5e578

Please sign in to comment.