Skip to content

Commit

Permalink
fix(alias): panic on nil pointer (close #4093)
Browse files Browse the repository at this point in the history
  • Loading branch information
xhofe committed Apr 9, 2023
1 parent c77eebb commit c0a6bee
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion drivers/alias/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ func (d *Alias) list(ctx context.Context, dst, sub string) ([]model.Obj, error)

func (d *Alias) link(ctx context.Context, dst, sub string, args model.LinkArgs) (*model.Link, error) {
reqPath := stdpath.Join(dst, sub)
storage, err := fs.GetStorage(reqPath, &fs.GetStoragesArgs{NoLog: true})
storage, err := fs.GetStorage(reqPath, &fs.GetStoragesArgs{})
if err != nil {
return nil, err
}
Expand Down
13 changes: 8 additions & 5 deletions internal/fs/fs.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ type ListArgs struct {
func List(ctx context.Context, path string, args *ListArgs) ([]model.Obj, error) {
res, err := list(ctx, path, args)
if err != nil {
log.Errorf("failed list %s: %+v", path, err)
if !args.NoLog {
log.Errorf("failed list %s: %+v", path, err)
}
return nil, err
}
return res, nil
Expand All @@ -33,8 +35,10 @@ type GetArgs struct {

func Get(ctx context.Context, path string, args *GetArgs) (model.Obj, error) {
res, err := get(ctx, path)
if err != nil && !args.NoLog {
log.Errorf("failed get %s: %+v", path, err)
if err != nil {
if !args.NoLog {
log.Errorf("failed get %s: %+v", path, err)
}
return nil, err
}
return res, nil
Expand Down Expand Up @@ -106,12 +110,11 @@ func PutAsTask(dstDirPath string, file *model.FileStream) error {
}

type GetStoragesArgs struct {
NoLog bool
}

func GetStorage(path string, args *GetStoragesArgs) (driver.Driver, error) {
storageDriver, _, err := op.GetStorageAndActualPath(path)
if err != nil && !args.NoLog {
if err != nil {
return nil, err
}
return storageDriver, nil
Expand Down

0 comments on commit c0a6bee

Please sign in to comment.