Skip to content

Commit

Permalink
fix nil pointers, lint
Browse files Browse the repository at this point in the history
Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de>
  • Loading branch information
butonic committed May 25, 2021
1 parent 78e1e4b commit ccc2403
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
3 changes: 3 additions & 0 deletions pkg/storage/fs/owncloud/owncloud.go
Original file line number Diff line number Diff line change
Expand Up @@ -2194,6 +2194,9 @@ func (fs *ocfs) RestoreRecycleItem(ctx context.Context, key string, restoreRef *
return nil
}

if restoreRef == nil {
restoreRef = &provider.Reference{}
}
if restoreRef.Path == "" {
v, err := xattr.Get(src, trashOriginPrefix)
if err != nil {
Expand Down
3 changes: 3 additions & 0 deletions pkg/storage/utils/decomposedfs/recycle.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,9 @@ func (fs *Decomposedfs) ListRecycle(ctx context.Context) (items []*provider.Recy

// RestoreRecycleItem restores the specified item
func (fs *Decomposedfs) RestoreRecycleItem(ctx context.Context, key string, restoreRef *provider.Reference) error {
if restoreRef == nil {
restoreRef = &provider.Reference{}
}
rn, restoreFunc, err := fs.tp.RestoreRecycleItemFunc(ctx, key, restoreRef.Path)
if err != nil {
return err
Expand Down
7 changes: 3 additions & 4 deletions pkg/storage/utils/localfs/localfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,13 +130,12 @@ func (fs *localfs) Shutdown(ctx context.Context) error {
return nil
}

func (fs *localfs) resolve(ctx context.Context, ref *provider.Reference) (string, error) {
func (fs *localfs) resolve(ctx context.Context, ref *provider.Reference) (p string, err error) {
if ref.StorageId != "" || ref.NodeId != "" {
if p, err := fs.GetPathByID(ctx, ref); err != nil {
if p, err = fs.GetPathByID(ctx, ref); err != nil {
return "", err
} else {
return path.Join(p, ref.Path), nil
}
return path.Join(p, ref.Path), nil
}

return ref.Path, nil
Expand Down

0 comments on commit ccc2403

Please sign in to comment.