1
0
Fork 0
mirror of https://github.com/documize/community.git synced 2025-07-19 13:19:43 +02:00

Fix issue with backup/restore of space labels

Closed #206
This commit is contained in:
sauls8t 2019-02-21 10:56:15 +00:00
parent ac84eaf85d
commit 9aaea9492a
6 changed files with 825 additions and 727 deletions

View file

@ -45,6 +45,7 @@ import (
"github.com/documize/community/model/category"
"github.com/documize/community/model/doc"
"github.com/documize/community/model/group"
"github.com/documize/community/model/label"
"github.com/documize/community/model/link"
"github.com/documize/community/model/page"
"github.com/documize/community/model/permission"
@ -170,6 +171,12 @@ func (b backerHandler) produce(id string) (files []backupItem, err error) {
return
}
// Space Label
err = b.dmzSpaceLabel(&files)
if err != nil {
return
}
// Space, Permission.
err = b.dmzSpace(&files)
if err != nil {
@ -452,6 +459,32 @@ func (b backerHandler) dmzPin(files *[]backupItem) (err error) {
return
}
// Space Label
func (b backerHandler) dmzSpaceLabel(files *[]backupItem) (err error) {
w := ""
if !b.Spec.SystemBackup() {
w = fmt.Sprintf(" WHERE c_orgid='%s' ", b.Spec.OrgID)
}
l := []label.Label{}
err = b.Runtime.Db.Select(&l, `
SELECT id, c_refid AS refid,
c_orgid AS orgid, c_name AS name, c_color AS color,
c_created AS created, c_revised AS revised
FROM dmz_space_label`+w)
if err != nil {
return errors.Wrap(err, "select.space_label")
}
content, err := toJSON(l)
if err != nil {
return errors.Wrap(err, "json.space_label")
}
*files = append(*files, backupItem{Filename: "dmz_space_label.json", Content: content})
return
}
// Space, Permission.
func (b backerHandler) dmzSpace(files *[]backupItem) (err error) {
w := ""