File tree Expand file tree Collapse file tree 2 files changed +10
-7
lines changed
scala/fr/brouillard/gitbucket/h2/controller
twirl/fr/brouillard/gitbucket/h2 Expand file tree Collapse file tree 2 files changed +10
-7
lines changed Original file line number Diff line number Diff 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}
Original file line number Diff line number Diff line change 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
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 >
You can’t perform that action at this time.
0 commit comments