Skip to content

Commit

Permalink
installer: Register gob types in init() function
Browse files Browse the repository at this point in the history
  • Loading branch information
livingsilver94 committed Nov 2, 2023
1 parent 3b17976 commit 57c28bd
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
3 changes: 1 addition & 2 deletions cli/privilege.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,13 @@ package cli
import (
"os"

"github.com/livingsilver94/backee/installer"
_ "github.com/livingsilver94/backee/installer"
priv "github.com/livingsilver94/backee/privilege"
)

type privilege struct{}

func (p privilege) Run() error {
installer.RegisterPrivilegedTypes()
run, err := priv.ReceiveRunner(os.Stdin)
if err != nil {
return err
Expand Down
12 changes: 6 additions & 6 deletions installer/fs.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ import (
"github.com/livingsilver94/backee/service"
)

func init() {
privilege.RegisterInterfaceImpl(SymlinkWriter{})
privilege.RegisterInterfaceImpl(CopyWriter{})
privilege.RegisterInterfaceImpl(privilegedPathWriter{})
}

type FileWriter interface {
loadSource(src string) error
writeDestination(dst string) error
Expand Down Expand Up @@ -47,12 +53,6 @@ func WritePathPrivileged(dst service.FilePath, src string, wr PrivilegedFileWrit
return privilege.Run(&r)
}

func RegisterPrivilegedTypes() {
privilege.RegisterInterfaceImpl(SymlinkWriter{})
privilege.RegisterInterfaceImpl(CopyWriter{})
privilege.RegisterInterfaceImpl(privilegedPathWriter{})
}

type SymlinkWriter struct {
srcPath string
}
Expand Down

0 comments on commit 57c28bd

Please sign in to comment.