diff --git a/README.md b/README.md index 4cb606b..0cdb894 100644 --- a/README.md +++ b/README.md @@ -32,6 +32,7 @@ - `--prefix=[CONTEXTPATH]` - `--host=[HOSTNAME]` - `--gitbucket.home=[DATA_DIR]` +- `--temp_dir=[TEMP_DIR]` You can also deploy gitbucket.war to a servlet container which supports Servlet 3.0 (like Jetty, Tomcat, JBoss, etc) diff --git a/src/main/java/JettyLauncher.java b/src/main/java/JettyLauncher.java index 01168e0..d810941 100644 --- a/src/main/java/JettyLauncher.java +++ b/src/main/java/JettyLauncher.java @@ -12,6 +12,7 @@ int port = 8080; InetSocketAddress address = null; String contextPath = "/"; + String tmpDirPath=""; boolean forceHttps = false; for(String arg: args) { @@ -29,6 +30,8 @@ } } else if(dim[0].equals("--gitbucket.home")){ System.setProperty("gitbucket.home", dim[1]); + } else if(dim[0].equals("--temp_dir")){ + tmpDirPath = dim[1]; } } } @@ -53,9 +56,21 @@ WebAppContext context = new WebAppContext(); - File tmpDir = new File(getGitBucketHome(), "tmp"); - if(!tmpDir.exists()){ - tmpDir.mkdirs(); + File tmpDir; + if(tmpDirPath.equals("")){ + tmpDir = new File(getGitBucketHome(), "tmp"); + if(!tmpDir.exists()){ + tmpDir.mkdirs(); + } + } else { + tmpDir = new File(tmpDirPath); + if(!tmpDir.exists()){ + throw new java.io.FileNotFoundException( + String.format("temp_dir \"%s\" not found", tmpDirPath)); + } else if(!tmpDir.isDirectory()) { + throw new IllegalArgumentException( + String.format("temp_dir \"%s\" is not a directory", tmpDirPath)); + } } context.setTempDirectory(tmpDir);