mirror of
https://github.com/gitbucket/gitbucket.git
synced 2025-11-08 22:45:51 +01:00
Removed FileUploadControllerBase(in the middle of improving file
upload).
This commit is contained in:
@@ -29,24 +29,10 @@ object Directory {
|
||||
}).getAbsolutePath
|
||||
|
||||
val GitBucketConf = new File(GitBucketHome, "gitbucket.conf")
|
||||
|
||||
|
||||
val RepositoryHome = s"${GitBucketHome}/repositories"
|
||||
|
||||
val DatabaseHome = s"${GitBucketHome}/data"
|
||||
|
||||
/**
|
||||
* Repository names of the specified user.
|
||||
*/
|
||||
def getRepositories(owner: String): List[String] =
|
||||
defining(new File(s"${RepositoryHome}/${owner}")){ dir =>
|
||||
if(dir.exists){
|
||||
dir.listFiles.filter { file =>
|
||||
file.isDirectory && !file.getName.endsWith(".wiki.git")
|
||||
}.map(_.getName.replaceFirst("\\.git$", "")).toList
|
||||
} else {
|
||||
Nil
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Substance directory of the repository.
|
||||
@@ -54,11 +40,23 @@ object Directory {
|
||||
def getRepositoryDir(owner: String, repository: String): File =
|
||||
new File(s"${RepositoryHome}/${owner}/${repository}.git")
|
||||
|
||||
/**
|
||||
* Directory for files which are attached to issue.
|
||||
*/
|
||||
def getAttachedDir(owner: String, repository: String): File =
|
||||
new File(s"${RepositoryHome}/${owner}/${repository}/issues")
|
||||
|
||||
/**
|
||||
* Directory for uploaded files by the specified user.
|
||||
*/
|
||||
def getUserUploadDir(userName: String): File = new File(s"${GitBucketHome}/data/${userName}/files")
|
||||
|
||||
/**
|
||||
* Root of temporary directories for the upload file.
|
||||
*/
|
||||
def getTemporaryDir(sessionId: String): File =
|
||||
new File(s"${GitBucketHome}/tmp/_upload/${sessionId}")
|
||||
|
||||
/**
|
||||
* Root of temporary directories for the specified repository.
|
||||
*/
|
||||
|
||||
@@ -4,6 +4,7 @@ import org.apache.commons.io.FileUtils
|
||||
import java.net.URLConnection
|
||||
import java.io.File
|
||||
import util.ControlUtil._
|
||||
import scala.util.Random
|
||||
|
||||
object FileUtil {
|
||||
|
||||
@@ -26,28 +27,12 @@ object FileUtil {
|
||||
}
|
||||
|
||||
def isImage(name: String): Boolean = getMimeType(name).startsWith("image/")
|
||||
|
||||
|
||||
def isLarge(size: Long): Boolean = (size > 1024 * 1000)
|
||||
|
||||
|
||||
def isText(content: Array[Byte]): Boolean = !content.contains(0)
|
||||
|
||||
// def createZipFile(dest: File, dir: File): Unit = {
|
||||
// def addDirectoryToZip(out: ZipArchiveOutputStream, dir: File, path: String): Unit = {
|
||||
// dir.listFiles.map { file =>
|
||||
// if(file.isFile){
|
||||
// out.putArchiveEntry(new ZipArchiveEntry(path + "/" + file.getName))
|
||||
// out.write(FileUtils.readFileToByteArray(file))
|
||||
// out.closeArchiveEntry
|
||||
// } else if(file.isDirectory){
|
||||
// addDirectoryToZip(out, file, path + "/" + file.getName)
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// using(new ZipArchiveOutputStream(dest)){ out =>
|
||||
// addDirectoryToZip(out, dir, dir.getName)
|
||||
// }
|
||||
// }
|
||||
def generateFileId: String = System.currentTimeMillis + Random.alphanumeric.take(10).mkString
|
||||
|
||||
def getFileName(path: String): String = defining(path.lastIndexOf('/')){ i =>
|
||||
if(i >= 0) path.substring(i + 1) else path
|
||||
|
||||
Reference in New Issue
Block a user