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 {
19
19
" dest" -> trim(label(" Destination" , text(required)))
20
20
)(BackupForm .apply)
21
21
22
+ private val defaultBackupFile : String = new File (GitBucketHome , " gitbucket-database-backup.zip" ).toString;
23
+
22
24
def exportDatabase (exportFile : File ): Unit = {
23
25
val session = Database .getSession(request)
24
26
val conn = session.conn
@@ -34,18 +36,19 @@ class H2BackupController extends ControllerBase {
34
36
}
35
37
36
38
get(" /admin/h2backup" ) {
37
- html.export(flash.get(" info" ));
39
+ html.export(flash.get(" info" ), flash.get( " dest " ).orElse( Some (defaultBackupFile)) );
38
40
}
39
41
40
42
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 )
42
44
exportDatabase(new File (filePath))
43
45
Ok (" done" )
44
46
}
45
47
46
48
post(" /database/backup" , backupForm) { form : BackupForm =>
47
49
exportDatabase(new File (form.destFile))
48
50
flash += " info" -> " H2 Database has been exported."
51
+ flash += " dest" -> form.destFile
49
52
redirect(" /admin/h2backup" )
50
53
}
51
54
}
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)
2
2
@import context._
3
3
@import gitbucket.core.html.main
4
4
@import gitbucket.core.admin.html.menu
10
10
@information(info)
11
11
< form action ="@path/database/backup " method ="POST ">
12
12
< div class ="box ">
13
- < div class ="box-header "> Database export </ div >
13
+ < div class ="box-header "> Database backup </ div >
14
14
< div class ="box-content ">
15
15
< fieldset >
16
- < label > < span class ="strong "> Database export file:</ span > </ label >
16
+ < label > < span class ="strong "> Database backup file:</ span > </ label >
17
17
< 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
19
19
</ 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 " />
21
21
</ fieldset >
22
22
23
23
</ div >
You can’t perform that action at this time.
0 commit comments