Skip to content

Commit 369a926

Browse files
ericbottardilayaperumalg
authored andcommitted
Use a new temporary directory for cache
Closes #6754 Signed-off-by: Eric Bottard <[email protected]>
1 parent 096f140 commit 369a926

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

‎models/spring-ai-transformers/src/main/java/org/springframework/ai/transformers/ResourceCacheService.java‎

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import java.io.File;
2020
import java.io.IOException;
2121
import java.net.URI;
22+
import java.nio.file.Files;
2223
import java.util.ArrayList;
2324
import java.util.List;
2425
import java.util.UUID;
@@ -56,7 +57,7 @@ public class ResourceCacheService {
5657
private List<String> excludedUriSchemas = new ArrayList<>(List.of("file", "classpath"));
5758

5859
public ResourceCacheService() {
59-
this(new File(System.getProperty("java.io.tmpdir"), "spring-ai-onnx-generative").getAbsolutePath());
60+
this(defaultCacheDirectory());
6061
}
6162

6263
public ResourceCacheService(String rootCacheDirectory) {
@@ -73,6 +74,15 @@ public ResourceCacheService(File rootCacheDirectory) {
7374
Assert.isTrue(this.cacheDirectory.isDirectory(), "The cache folder must be a directory");
7475
}
7576

77+
private static File defaultCacheDirectory() {
78+
try {
79+
return Files.createTempDirectory("spring-ai-model-cache").toFile();
80+
}
81+
catch (IOException e) {
82+
throw new RuntimeException(e);
83+
}
84+
}
85+
7686
/**
7787
* Overrides the excluded URI schemas list.
7888
* @param excludedUriSchemas new list of URI schemas to be excluded from caching.

0 commit comments

Comments
 (0)