Skip to content

Commit

Permalink
Make local file connector more error tolerant (#1625)
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel-WWU-IT authored Apr 9, 2021
1 parent 46e3efb commit 1765ae8
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
5 changes: 5 additions & 0 deletions changelog/unreleased/fix-mentix-local-file.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Bugfix: Make local file connector more error tolerant

The local file connector caused Reva to throw an exception if the local file for storing site data couldn't be loaded. This PR changes this behavior so that only a warning is logged.

https://github.com/cs3org/reva/pull/1625
19 changes: 9 additions & 10 deletions pkg/mentix/connectors/localfile.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,22 +64,21 @@ func (connector *LocalFileConnector) Activate(conf *config.Configuration, log *z

// RetrieveMeshData fetches new mesh data.
func (connector *LocalFileConnector) RetrieveMeshData() (*meshdata.MeshData, error) {
meshData := &meshdata.MeshData{}

jsonData, err := ioutil.ReadFile(connector.filePath)
if err != nil {
return nil, fmt.Errorf("unable to read file '%v': %v", connector.filePath, err)
connector.log.Warn().Err(err).Msgf("unable to read file '%v'", connector.filePath)
return &meshdata.MeshData{}, nil
}

if err := json.Unmarshal(jsonData, &meshData.Sites); err != nil {
return nil, fmt.Errorf("invalid file '%v': %v", connector.filePath, err)
meshData := &meshdata.MeshData{}
if err := json.Unmarshal(jsonData, &meshData.Sites); err == nil {
// Enforce site types
connector.setSiteTypes(meshData)
meshData.InferMissingData()
} else {
connector.log.Warn().Err(err).Msgf("invalid file '%v'", connector.filePath)
}

// Enforce site types
connector.setSiteTypes(meshData)

meshData.InferMissingData()

return meshData, nil
}

Expand Down

0 comments on commit 1765ae8

Please sign in to comment.