From b372c71fbf474dd3e29f43b10aa341007e8fc45c Mon Sep 17 00:00:00 2001 From: Skull Writter <7103685+skullwritter@users.noreply.github.com> Date: Sun, 25 Aug 2019 17:43:47 +0000 Subject: [PATCH] Add --upload_timeout bootstrap option (#2363) --- README.md | 1 + src/main/java/JettyLauncher.java | 3 +++ src/main/scala/gitbucket/core/util/FileUtil.scala | 6 ++++++ src/main/twirl/gitbucket/core/helper/attached.scala.html | 2 ++ src/main/twirl/gitbucket/core/releases/form.scala.html | 2 ++ 5 files changed, 14 insertions(+) diff --git a/README.md b/README.md index 642e17dbc..b83363c06 100644 --- a/README.md +++ b/README.md @@ -39,6 +39,7 @@ You can specify following options: - `--gitbucket.home=[DATA_DIR]` - `--temp_dir=[TEMP_DIR]` - `--max_file_size=[MAX_FILE_SIZE]` +- `--upload_timeout=[MAX_UPLOAD_TIMEOUT]` `TEMP_DIR` is used as the [temporary directory for the jetty application context](https://www.eclipse.org/jetty/documentation/9.3.x/ref-temporary-directories.html). This is the directory into which the `gitbucket.war` file is unpacked, the source files are compiled, etc. If given this parameter **must** match the path of an existing directory or the application will quit reporting an error; if not given the path used will be a `tmp` directory inside the gitbucket home. diff --git a/src/main/java/JettyLauncher.java b/src/main/java/JettyLauncher.java index 274654ab1..93f27ef01 100644 --- a/src/main/java/JettyLauncher.java +++ b/src/main/java/JettyLauncher.java @@ -42,6 +42,9 @@ public class JettyLauncher { case "--max_file_size": System.setProperty("gitbucket.maxFileSize", dim[1]); break; + case "--upload_timeout": + System.setProperty("gitbucket.UploadTimeout", dim[1]); + break; case "--gitbucket.home": System.setProperty("gitbucket.home", dim[1]); break; diff --git a/src/main/scala/gitbucket/core/util/FileUtil.scala b/src/main/scala/gitbucket/core/util/FileUtil.scala index 5da060dd8..e3e50acea 100644 --- a/src/main/scala/gitbucket/core/util/FileUtil.scala +++ b/src/main/scala/gitbucket/core/util/FileUtil.scala @@ -96,4 +96,10 @@ object FileUtil { else 3 * 1024 * 1024 + lazy val UploadTimeout = + if (System.getProperty("gitbucket.UploadTimeout") != null) + System.getProperty("gitbucket.UploadTimeout").toLong + else + 3 * 10000 + } diff --git a/src/main/twirl/gitbucket/core/helper/attached.scala.html b/src/main/twirl/gitbucket/core/helper/attached.scala.html index 45469ac2a..15a822a28 100644 --- a/src/main/twirl/gitbucket/core/helper/attached.scala.html +++ b/src/main/twirl/gitbucket/core/helper/attached.scala.html @@ -66,6 +66,8 @@ $(function(){ @dropzone(clickable: Boolean, textareaId: Option[String]) = { url: '@context.path/upload/file/@repository.owner/@repository.name', maxFilesize: @{FileUtil.MaxFileSize / 1024 / 1024}, + //timeout defaults to 30 secs + timeout: @{FileUtil.UploadTimeout}, clickable: @clickable, previewTemplate: "