diff options
author | Harald Musum <musum@yahooinc.com> | 2024-02-22 18:07:59 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-02-22 18:07:59 +0100 |
commit | 7c11a34e806cd1e8325d793c950d4246e65e23bd (patch) | |
tree | a249fd87bf702441e3b08ebb488b92fda9969938 /config-model | |
parent | 60cfb23d326c2aac7e443094fc5d49d46e2370e7 (diff) | |
parent | 6d4fc9aae463537ac1c3c717c45850176602a0d5 (diff) |
Merge pull request #30375 from vespa-engine/hmusum/more-robust-handling-when-creating-dir
Create directories in a more robust way
Diffstat (limited to 'config-model')
-rw-r--r-- | config-model/src/main/java/com/yahoo/vespa/model/ml/ConvertedModel.java | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/config-model/src/main/java/com/yahoo/vespa/model/ml/ConvertedModel.java b/config-model/src/main/java/com/yahoo/vespa/model/ml/ConvertedModel.java index f007065a0c2..621377e0606 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/ml/ConvertedModel.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/ml/ConvertedModel.java @@ -30,6 +30,7 @@ import java.io.File; import java.io.IOException; import java.io.StringReader; import java.io.UncheckedIOException; +import java.nio.file.Files; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; @@ -41,6 +42,8 @@ import java.util.Optional; import java.util.Set; import java.util.stream.Collectors; +import static com.yahoo.yolean.Exceptions.uncheck; + /** * A machine learned model imported from the models/ directory in the application package, for a single rank profile. * This encapsulates the difference between reading a model @@ -635,11 +638,7 @@ public class ConvertedModel { } private void createIfNeeded(Path path) { - File dir = application.getFileReference(path); - if ( ! dir.exists()) { - if (!dir.mkdirs()) - throw new IllegalStateException("Could not create " + dir); - } + uncheck(() -> Files.createDirectories(application.getFileReference(path).toPath())); } } |