Skip to content

Commit 1074d15

Browse files
committed
use Forms from Scalatra directly.
1 parent b3aacbc commit 1074d15

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/main/scala/fr/brouillard/gitbucket/h2/controller/H2BackupController.scala

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import gitbucket.core.servlet.Database
1313
import org.scalatra.Ok
1414
import org.slf4j.LoggerFactory
1515

16-
import io.github.gitbucket.scalatra.forms._
16+
import org.scalatra.forms._
1717

1818
class H2BackupController extends ControllerBase with AdminAuthenticator {
1919
private val logger = LoggerFactory.getLogger(classOf[H2BackupController])
@@ -27,7 +27,7 @@ class H2BackupController extends ControllerBase with AdminAuthenticator {
2727
// private val defaultBackupFile:String = new File(GitBucketHome, "gitbucket-database-backup.zip").toString;
2828

2929
def exportDatabase(exportFile: File): Unit = {
30-
val destFile = if (exportFile.isAbsolute()) exportFile else new File(GitBucketHome+"/backup", exportFile.toString)
30+
val destFile = if (exportFile.isAbsolute()) exportFile else new File(GitBucketHome + "/backup", exportFile.toString)
3131

3232
val session = Database.getSession(request)
3333
val conn = session.conn
@@ -37,13 +37,13 @@ class H2BackupController extends ControllerBase with AdminAuthenticator {
3737
conn.prepareStatement("BACKUP TO '" + destFile + "'").execute()
3838
}
3939

40-
get("/admin/h2backup") (adminOnly {
40+
get("/admin/h2backup")(adminOnly {
4141
html.export(flash.get("info"), flash.get("dest").orElse(Some(defaultBackupFileName())))
4242
})
4343

4444
get("/api/v3/plugins/database/backup") {
4545
context.loginAccount match {
46-
case Some(x) if(x.isAdmin) => doExport()
46+
case Some(x) if (x.isAdmin) => doExport()
4747
case _ => org.scalatra.Unauthorized()
4848
}
4949
}
@@ -57,21 +57,21 @@ class H2BackupController extends ControllerBase with AdminAuthenticator {
5757
}
5858

5959
private def doExport(): Unit = {
60-
val filePath:String = params.getOrElse("dest", defaultBackupFileName())
60+
val filePath: String = params.getOrElse("dest", defaultBackupFileName())
6161
exportDatabase(new File(filePath))
6262
Ok("done: " + filePath)
6363
}
6464

6565
post("/database/backup", backupForm) { form: BackupForm =>
6666
exportDatabase(new File(form.destFile))
67-
val msg:String = "H2 Database has been exported to '"+form.destFile+"'."
67+
val msg: String = "H2 Database has been exported to '" + form.destFile + "'."
6868
flash += "info" -> msg
6969
flash += "dest" -> form.destFile
7070
redirect("/admin/h2backup")
7171
}
7272

7373
private def defaultBackupFileName(): String = {
7474
val format = new java.text.SimpleDateFormat("yyyy-MM-dd_HH-mm")
75-
"gitbucket-db-" + format.format(new Date())+ ".zip"
75+
"gitbucket-db-" + format.format(new Date()) + ".zip"
7676
}
7777
}

0 commit comments

Comments
 (0)