mirror of
https://github.com/gitbucket/gitbucket.git
synced 2026-05-07 07:35:44 +02:00
(refs #1101)Remove LFS setting
This commit is contained in:
@@ -300,7 +300,7 @@ trait RepositoryViewerControllerBase extends ControllerBase {
|
||||
JGitUtil.getObjectLoaderFromId(git, objectId){ loader =>
|
||||
contentType = FileUtil.getMimeType(path)
|
||||
|
||||
if(loader.isLarge || context.settings.lfs.serverUrl.isEmpty){
|
||||
if(loader.isLarge){
|
||||
response.setContentLength(loader.getSize.toInt)
|
||||
loader.copyTo(response.outputStream)
|
||||
} else {
|
||||
@@ -317,7 +317,7 @@ trait RepositoryViewerControllerBase extends ControllerBase {
|
||||
response.setContentLength(attrs("size").toInt)
|
||||
val oid = attrs("oid").split(":")(1)
|
||||
|
||||
using(new FileInputStream(Directory.LfsHome + "/" + oid.substring(0, 2) + "/" + oid.substring(2, 4) + "/" + oid)){ in =>
|
||||
using(new FileInputStream(FileUtil.getLfsFilePath(oid))){ in =>
|
||||
IOUtils.copy(in, response.getOutputStream)
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -58,10 +58,7 @@ trait SystemSettingsControllerBase extends AccountManagementControllerBase {
|
||||
"tls" -> trim(label("Enable TLS", optional(boolean()))),
|
||||
"ssl" -> trim(label("Enable SSL", optional(boolean()))),
|
||||
"keystore" -> trim(label("Keystore", optional(text())))
|
||||
)(Ldap.apply)),
|
||||
"lfs" -> mapping(
|
||||
"serverUrl" -> trim(label("LDAP host", optional(text())))
|
||||
)(Lfs.apply)
|
||||
)(Ldap.apply))
|
||||
)(SystemSettings.apply).verifying { settings =>
|
||||
Vector(
|
||||
if(settings.ssh && settings.baseUrl.isEmpty){
|
||||
|
||||
@@ -53,7 +53,6 @@ trait SystemSettingsService {
|
||||
ldap.keystore.foreach(x => props.setProperty(LdapKeystore, x))
|
||||
}
|
||||
}
|
||||
settings.lfs.serverUrl.foreach { x => props.setProperty(LfsServerUrl, x) }
|
||||
using(new java.io.FileOutputStream(GitBucketConf)){ out =>
|
||||
props.store(out, null)
|
||||
}
|
||||
@@ -110,10 +109,7 @@ trait SystemSettingsService {
|
||||
getOptionValue(props, LdapKeystore, None)))
|
||||
} else {
|
||||
None
|
||||
},
|
||||
Lfs(
|
||||
getOptionValue(props, LfsServerUrl, None)
|
||||
)
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -138,8 +134,7 @@ object SystemSettingsService {
|
||||
useSMTP: Boolean,
|
||||
smtp: Option[Smtp],
|
||||
ldapAuthentication: Boolean,
|
||||
ldap: Option[Ldap],
|
||||
lfs: Lfs){
|
||||
ldap: Option[Ldap]){
|
||||
def baseUrl(request: HttpServletRequest): String = baseUrl.fold(request.baseUrl)(_.stripSuffix("/"))
|
||||
|
||||
def sshAddress:Option[SshAddress] =
|
||||
@@ -220,7 +215,6 @@ object SystemSettingsService {
|
||||
private val LdapTls = "ldap.tls"
|
||||
private val LdapSsl = "ldap.ssl"
|
||||
private val LdapKeystore = "ldap.keystore"
|
||||
private val LfsServerUrl = "lfs.server_url"
|
||||
|
||||
private def getValue[A: ClassTag](props: java.util.Properties, key: String, default: A): A =
|
||||
defining(props.getProperty(key)){ value =>
|
||||
|
||||
@@ -4,7 +4,7 @@ import java.io.{File, FileInputStream, FileOutputStream}
|
||||
import java.text.MessageFormat
|
||||
import javax.servlet.http.{HttpServlet, HttpServletRequest, HttpServletResponse}
|
||||
|
||||
import gitbucket.core.util.Directory
|
||||
import gitbucket.core.util.{Directory, FileUtil}
|
||||
import org.apache.commons.io.{FileUtils, IOUtils}
|
||||
import org.json4s.jackson.Serialization._
|
||||
import org.apache.http.HttpStatus
|
||||
@@ -24,7 +24,7 @@ class GitLfsTransferServlet extends HttpServlet {
|
||||
for {
|
||||
oid <- getObjectId(req, res)
|
||||
} yield {
|
||||
val file = new File(Directory.LfsHome + "/" + oid.substring(0, 2) + "/" + oid.substring(2, 4) + "/" + oid)
|
||||
val file = new File(FileUtil.getLfsFilePath(oid))
|
||||
if(file.exists()){
|
||||
res.setStatus(HttpStatus.SC_OK)
|
||||
res.setContentType("application/octet-stream")
|
||||
@@ -44,7 +44,7 @@ class GitLfsTransferServlet extends HttpServlet {
|
||||
for {
|
||||
oid <- getObjectId(req, res)
|
||||
} yield {
|
||||
val file = new File(Directory.LfsHome + "/" + oid.substring(0, 2) + "/" + oid.substring(2, 4) + "/" + oid)
|
||||
val file = new File(FileUtil.getLfsFilePath(oid))
|
||||
FileUtils.forceMkdir(file.getParentFile)
|
||||
using(req.getInputStream, new FileOutputStream(file)){ (in, out) =>
|
||||
IOUtils.copy(in, out)
|
||||
|
||||
@@ -69,18 +69,18 @@ class GitRepositoryServlet extends GitServlet with SystemSettingsService {
|
||||
val batchRequest = read[GitLfs.BatchRequest](req.getInputStream)
|
||||
val settings = loadSystemSettings()
|
||||
|
||||
settings.lfs.serverUrl match {
|
||||
settings.baseUrl match {
|
||||
case None =>
|
||||
throw new IllegalStateException("lfs.server_url is not configured.")
|
||||
|
||||
case Some(serverUrl) =>
|
||||
case Some(baseUrl) =>
|
||||
val batchResponse = batchRequest.operation match {
|
||||
case "upload" =>
|
||||
GitLfs.BatchUploadResponse("basic", batchRequest.objects.map { requestObject =>
|
||||
GitLfs.BatchResponseObject(requestObject.oid, requestObject.size, true,
|
||||
GitLfs.Actions(
|
||||
upload = Some(GitLfs.Action(
|
||||
href = serverUrl + "/" + requestObject.oid,
|
||||
href = baseUrl + "/git-lfs/" + requestObject.oid,
|
||||
expires_at = new Date(System.currentTimeMillis + 60000L)
|
||||
))
|
||||
)
|
||||
@@ -91,7 +91,7 @@ class GitRepositoryServlet extends GitServlet with SystemSettingsService {
|
||||
GitLfs.BatchResponseObject(requestObject.oid, requestObject.size, true,
|
||||
GitLfs.Actions(
|
||||
download = Some(GitLfs.Action(
|
||||
href = serverUrl + "/" + requestObject.oid,
|
||||
href = baseUrl + "/git-lfs/" + requestObject.oid,
|
||||
expires_at = new Date(System.currentTimeMillis + 60000L)
|
||||
))
|
||||
)
|
||||
|
||||
@@ -62,4 +62,8 @@ object FileUtil {
|
||||
"image/jpeg",
|
||||
"image/png",
|
||||
"text/plain")
|
||||
|
||||
def getLfsFilePath(oid: String): String =
|
||||
Directory.LfsHome + "/" + oid.substring(0, 2) + "/" + oid.substring(2, 4) + "/" + oid
|
||||
|
||||
}
|
||||
|
||||
@@ -314,6 +314,7 @@
|
||||
<!--====================================================================-->
|
||||
<!-- GitLFS -->
|
||||
<!--====================================================================-->
|
||||
@*
|
||||
<hr>
|
||||
<label class="strong">
|
||||
GitLFS <span class="muted normal">(Put LFS server url to enable GitLFS support)</span>
|
||||
@@ -325,6 +326,7 @@
|
||||
<span id="error-lfs_serverUrl" class="error"></span>
|
||||
</div>
|
||||
</div>
|
||||
*@
|
||||
</div>
|
||||
</div>
|
||||
<div class="align-right" style="margin-top: 20px;">
|
||||
|
||||
Reference in New Issue
Block a user