Skip to content

Commit

Permalink
update temp directory
Browse files Browse the repository at this point in the history
  • Loading branch information
wh1t3p1g committed Mar 18, 2024
1 parent c83b75a commit 3eb7013
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/main/java/tabby/common/utils/FileUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ public static void putRawContent(String path, Collection<String> data){
*/
public static Path registerTempDirectory(String directory) throws IOException {

final Path tmpDir = Files.createTempDirectory("tabby_"+directory);
final Path tmpDir = createTempDirectory("tabby_"+directory);
// Delete the temp directory at shutdown
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
try {
Expand All @@ -241,6 +241,14 @@ public static Path registerTempDirectory(String directory) throws IOException {
return tmpDir;
}

public static Path createTempDirectory(String directory){
String filepath = String.join(File.separator, GlobalConfiguration.TEMP_PATH, directory + UUID.randomUUID());
if(!fileExists(filepath)){
createDirectory(filepath);
}
return Paths.get(filepath);
}

/**
* Recursively delete the directory root and all its contents
* @param root Root directory to be deleted
Expand Down
1 change: 1 addition & 0 deletions src/main/java/tabby/config/GlobalConfiguration.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public class GlobalConfiguration {
public static String CONFIG_FILE_PATH = String.join(File.separator, System.getProperty("user.dir"), "config", "settings.properties");
public static String LIBS_PATH = String.join(File.separator, System.getProperty("user.dir"), "libs");
public static String JRE_LIBS_PATH = String.join(File.separator, System.getProperty("user.dir"), "jre_libs");
public static String TEMP_PATH = String.join(File.separator, System.getProperty("user.dir"), "temp");
public static String RULES_PATH;
public static String SINK_RULE_PATH;
public static String SYSTEM_RULE_PATH;
Expand Down

0 comments on commit 3eb7013

Please sign in to comment.