(refs #1101)Remove LFS setting

This commit is contained in:
Naoki Takezoe
2017-01-04 07:34:04 +09:00
parent 9cded1b4de
commit 3b99e619db
7 changed files with 18 additions and 21 deletions

View File

@@ -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 {

View File

@@ -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){

View File

@@ -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 =>

View File

@@ -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)

View File

@@ -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)
))
)

View File

@@ -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
}

View File

@@ -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;">