@@ -132,11 +132,7 @@ protected boolean saveBytesToFile(
132
132
try {
133
133
Files .write (path , bytes .toArray ());
134
134
} 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 );
140
136
} catch (IOException e ) {
141
137
LOG .error ("Failed to save {} bytes to file." , description , e );
142
138
return false ;
@@ -145,8 +141,14 @@ protected boolean saveBytesToFile(
145
141
}
146
142
147
143
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
+ }
150
152
try {
151
153
Files .write (path , bytes .toArray ());
152
154
} catch (IOException e ) {
0 commit comments