Skip to content
This repository was archived by the owner on Aug 7, 2025. It is now read-only.

Commit eae1ff8

Browse files
committed
add validation funcion
1 parent 2c9f6c3 commit eae1ff8

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

frontend/server/src/main/java/org/pytorch/serve/wlm/ModelManager.java

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -239,10 +239,7 @@ private void setupModelDependencies(Model model)
239239
null);
240240

241241
ProcessBuilder processBuilder = new ProcessBuilder(commandParts);
242-
if (dependencyPath
243-
.toPath()
244-
.normalize()
245-
.startsWith(FileUtils.getTempDirectory().toPath().normalize())) {
242+
if (isValidDependencyPath(dependencyPath)) {
246243
processBuilder.directory(dependencyPath);
247244
} else {
248245
throw new ModelException(
@@ -285,6 +282,16 @@ private void setupModelDependencies(Model model)
285282
}
286283
}
287284

285+
private boolean isValidDependencyPath(File dependencyPath) {
286+
if (dependencyPath
287+
.toPath()
288+
.normalize()
289+
.startsWith(FileUtils.getTempDirectory().toPath().normalize())) {
290+
return true;
291+
}
292+
return false;
293+
}
294+
288295
private Model createModel(
289296
ModelArchive archive,
290297
int batchSize,

0 commit comments

Comments
 (0)