Skip to content

Commit ce9bc5b

Browse files
committed
refresh backup page with file location used for backup action, closes #4
1 parent 04b4189 commit ce9bc5b

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ class H2BackupController extends ControllerBase {
1919
"dest" -> trim(label("Destination", text(required)))
2020
)(BackupForm.apply)
2121

22+
private val defaultBackupFile:String = new File(GitBucketHome, "gitbucket-database-backup.zip").toString;
23+
2224
def exportDatabase(exportFile: File): Unit = {
2325
val session = Database.getSession(request)
2426
val conn = session.conn
@@ -34,18 +36,19 @@ class H2BackupController extends ControllerBase {
3436
}
3537

3638
get("/admin/h2backup") {
37-
html.export(flash.get("info"));
39+
html.export(flash.get("info"), flash.get("dest").orElse(Some(defaultBackupFile)));
3840
}
3941

4042
get("/database/backup") {
41-
val filePath:String = params.getOrElse("dest", new File(GitBucketHome, "gitbucket-database-backup.zip").toString)
43+
val filePath:String = params.getOrElse("dest", defaultBackupFile)
4244
exportDatabase(new File(filePath))
4345
Ok("done")
4446
}
4547

4648
post("/database/backup", backupForm) { form: BackupForm =>
4749
exportDatabase(new File(form.destFile))
4850
flash += "info" -> "H2 Database has been exported."
51+
flash += "dest" -> form.destFile
4952
redirect("/admin/h2backup")
5053
}
5154
}

src/main/twirl/fr/brouillard/gitbucket/h2/export.scala.html

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
@(info: Option[Any])(implicit context: gitbucket.core.controller.Context)
1+
@(info: Option[Any], dest: Option[Any])(implicit context: gitbucket.core.controller.Context)
22
@import context._
33
@import gitbucket.core.html.main
44
@import gitbucket.core.admin.html.menu
@@ -10,14 +10,14 @@
1010
@information(info)
1111
<form action="@path/database/backup" method="POST">
1212
<div class="box">
13-
<div class="box-header">Database export</div>
13+
<div class="box-header">Database backup</div>
1414
<div class="box-content">
1515
<fieldset>
16-
<label><span class="strong">Database export file:</span></label>
16+
<label><span class="strong">Database backup file:</span></label>
1717
<p class="muted">
18-
Allows to export the database content. The same action can be achieved via an HTTP GET call to @path/database/backup
18+
Allows to export/backup the database content. The same action can be achieved via an HTTP GET call to @path/database/backup
1919
</p>
20-
<input type="text" name="dest" value="@GitBucketHome/gitbucket-database-backup.zip" style="width: 400px" />
20+
<input type="text" name="dest" value="@dest" style="width: 400px" />
2121
</fieldset>
2222

2323
</div>

0 commit comments

Comments
 (0)