Skip to content

Commit

Permalink
fix initialization of shares json file
Browse files Browse the repository at this point in the history
Signed-off-by: David Christofas <dchristofas@owncloud.com>
  • Loading branch information
David Christofas committed Jul 6, 2020
1 parent 6e75598 commit 3ea2fc5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
8 changes: 8 additions & 0 deletions changelog/unreleased/fix-json-sharemanager-initialization.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Bugfix: Fix initialization of json share manager

When an empty shares.json file existed the json share manager would fail while
trying to unmarshal the empty file.

https://github.com/cs3org/reva/issues/941
https://github.com/cs3org/reva/pull/940

4 changes: 2 additions & 2 deletions pkg/share/manager/json/json.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ func New(m map[string]interface{}) (share.Manager, error) {
}

func loadOrCreate(file string) (*shareModel, error) {
_, err := os.Stat(file)
if os.IsNotExist(err) {
info, err := os.Stat(file)
if os.IsNotExist(err) || info.Size() == 0 {
if err := ioutil.WriteFile(file, []byte("{}"), 0700); err != nil {
err = errors.Wrap(err, "error opening/creating the file: "+file)
return nil, err
Expand Down

0 comments on commit 3ea2fc5

Please sign in to comment.