Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions node/backup/controller.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package backup

import (
"encoding/json"
"errors"
"os"
"path/filepath"
Expand All @@ -10,6 +11,7 @@ import (
"go.uber.org/zap"

"github.com/status-im/status-go/common"
"github.com/status-im/status-go/signal"
)

type BackupConfig struct {
Expand All @@ -33,6 +35,19 @@ type Controller struct {
wg *sync.WaitGroup
}

type BackUpCompletedEvent struct {
FileName string
}

func (b BackUpCompletedEvent) MarshalJSON() ([]byte, error) {
responseItem := struct {
FileName string `json:"fileName,omitempty"`
}{
FileName: b.FileName,
}
return json.Marshal(responseItem)
}

func NewController(config BackupConfig, logger *zap.Logger) (*Controller, error) {
if len(config.PrivateKey) == 0 {
return nil, errors.New("private key must be provided")
Expand Down Expand Up @@ -116,6 +131,10 @@ func (c *Controller) PerformBackup() (string, error) {
return "", err
}

signal.SendLocalBackUpCompleted(BackUpCompletedEvent{
FileName: fileName,
})

return fileName, nil
}

Expand Down
6 changes: 6 additions & 0 deletions signal/events_backup_sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ const (

// EventBackedUpSettings is emitted while applying backed up settings
EventBackedUpSettings = "backedup.settings"

EventLocalBackUpCompleted = "backup.local.completed"
)

func SendBackedUpProfile(obj json.Marshaler) {
Expand All @@ -17,3 +19,7 @@ func SendBackedUpProfile(obj json.Marshaler) {
func SendBackedUpSettings(obj json.Marshaler) {
send(EventBackedUpSettings, obj)
}

func SendLocalBackUpCompleted(obj json.Marshaler) {
send(EventLocalBackUpCompleted, obj)
}