replace third_party with go get and fix accounts / settings tests
This commit is contained in:
@@ -4,12 +4,18 @@ import (
|
||||
"io/ioutil"
|
||||
"os"
|
||||
|
||||
"github.com/owncloud/ocis/settings/pkg/store/errortypes"
|
||||
"google.golang.org/protobuf/encoding/protojson"
|
||||
"google.golang.org/protobuf/proto"
|
||||
)
|
||||
|
||||
// Unmarshal file into record
|
||||
func (s Store) parseRecordFromFile(record proto.Message, filePath string) error {
|
||||
_, err := os.Stat(filePath)
|
||||
if err != nil {
|
||||
return errortypes.BundleNotFound(err.Error())
|
||||
}
|
||||
|
||||
file, err := os.Open(filePath)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -21,6 +27,10 @@ func (s Store) parseRecordFromFile(record proto.Message, filePath string) error
|
||||
return err
|
||||
}
|
||||
|
||||
if len(b) == 0 {
|
||||
return errortypes.BundleNotFound(filePath)
|
||||
}
|
||||
|
||||
if err := protojson.Unmarshal(b, record); err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -35,10 +45,12 @@ func (s Store) writeRecordToFile(record proto.Message, filePath string) error {
|
||||
}
|
||||
defer file.Close()
|
||||
|
||||
if v, err := protojson.Marshal(record); err != nil {
|
||||
file.Write(v)
|
||||
v, err := protojson.Marshal(record)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
file.Write(v)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user