Skip to content

Commit

Permalink
Move directory creation
Browse files Browse the repository at this point in the history
  • Loading branch information
courtneyeh committed Apr 15, 2024
1 parent 3a36a97 commit 3c17786
Showing 1 changed file with 9 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -132,11 +132,7 @@ protected boolean saveBytesToFile(
try {
Files.write(path, bytes.toArray());
} catch (NoSuchFileException e) {
if (!path.getParent().toFile().mkdirs()) {
LOG.error("Failed to save {} bytes to file.", description, e);
return false;
}
return saveAfterCreatingTopicDirectory(description, relativeFilePath, bytes);
return saveAfterCreatingTopicDirectory(description, path, relativeFilePath, bytes);
} catch (IOException e) {
LOG.error("Failed to save {} bytes to file.", description, e);
return false;
Expand All @@ -145,8 +141,14 @@ protected boolean saveBytesToFile(
}

private boolean saveAfterCreatingTopicDirectory(
final String description, final Path relativeFilePath, final Bytes bytes) {
final Path path = directory.resolve(relativeFilePath);
final String description, final Path path, final Path relativeFilePath, final Bytes bytes) {
if (!path.getParent().toFile().mkdirs()) {
LOG.error(
"Failed to save {} bytes to file. No such directory {} to save file.",
description,
relativeFilePath.getParent());
return false;
}
try {
Files.write(path, bytes.toArray());
} catch (IOException e) {
Expand Down

0 comments on commit 3c17786

Please sign in to comment.