Skip to content

Commit c0a6bee

Browse files
committed
fix(alias): panic on nil pointer (close #4093)
1 parent c77eebb commit c0a6bee

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

drivers/alias/util.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ func (d *Alias) list(ctx context.Context, dst, sub string) ([]model.Obj, error)
8383

8484
func (d *Alias) link(ctx context.Context, dst, sub string, args model.LinkArgs) (*model.Link, error) {
8585
reqPath := stdpath.Join(dst, sub)
86-
storage, err := fs.GetStorage(reqPath, &fs.GetStoragesArgs{NoLog: true})
86+
storage, err := fs.GetStorage(reqPath, &fs.GetStoragesArgs{})
8787
if err != nil {
8888
return nil, err
8989
}

internal/fs/fs.go

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ type ListArgs struct {
2121
func List(ctx context.Context, path string, args *ListArgs) ([]model.Obj, error) {
2222
res, err := list(ctx, path, args)
2323
if err != nil {
24-
log.Errorf("failed list %s: %+v", path, err)
24+
if !args.NoLog {
25+
log.Errorf("failed list %s: %+v", path, err)
26+
}
2527
return nil, err
2628
}
2729
return res, nil
@@ -33,8 +35,10 @@ type GetArgs struct {
3335

3436
func Get(ctx context.Context, path string, args *GetArgs) (model.Obj, error) {
3537
res, err := get(ctx, path)
36-
if err != nil && !args.NoLog {
37-
log.Errorf("failed get %s: %+v", path, err)
38+
if err != nil {
39+
if !args.NoLog {
40+
log.Errorf("failed get %s: %+v", path, err)
41+
}
3842
return nil, err
3943
}
4044
return res, nil
@@ -106,12 +110,11 @@ func PutAsTask(dstDirPath string, file *model.FileStream) error {
106110
}
107111

108112
type GetStoragesArgs struct {
109-
NoLog bool
110113
}
111114

112115
func GetStorage(path string, args *GetStoragesArgs) (driver.Driver, error) {
113116
storageDriver, _, err := op.GetStorageAndActualPath(path)
114-
if err != nil && !args.NoLog {
117+
if err != nil {
115118
return nil, err
116119
}
117120
return storageDriver, nil

0 commit comments

Comments
 (0)