Skip to content

Commit 3c17786

Browse files
committed
Move directory creation
1 parent 3a36a97 commit 3c17786

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

Diff for: ethereum/statetransition/src/main/java/tech/pegasys/teku/statetransition/util/DebugDataDumper.java

+9-7
Original file line numberDiff line numberDiff line change
@@ -132,11 +132,7 @@ protected boolean saveBytesToFile(
132132
try {
133133
Files.write(path, bytes.toArray());
134134
} catch (NoSuchFileException e) {
135-
if (!path.getParent().toFile().mkdirs()) {
136-
LOG.error("Failed to save {} bytes to file.", description, e);
137-
return false;
138-
}
139-
return saveAfterCreatingTopicDirectory(description, relativeFilePath, bytes);
135+
return saveAfterCreatingTopicDirectory(description, path, relativeFilePath, bytes);
140136
} catch (IOException e) {
141137
LOG.error("Failed to save {} bytes to file.", description, e);
142138
return false;
@@ -145,8 +141,14 @@ protected boolean saveBytesToFile(
145141
}
146142

147143
private boolean saveAfterCreatingTopicDirectory(
148-
final String description, final Path relativeFilePath, final Bytes bytes) {
149-
final Path path = directory.resolve(relativeFilePath);
144+
final String description, final Path path, final Path relativeFilePath, final Bytes bytes) {
145+
if (!path.getParent().toFile().mkdirs()) {
146+
LOG.error(
147+
"Failed to save {} bytes to file. No such directory {} to save file.",
148+
description,
149+
relativeFilePath.getParent());
150+
return false;
151+
}
150152
try {
151153
Files.write(path, bytes.toArray());
152154
} catch (IOException e) {

0 commit comments

Comments
 (0)