fix(alias): panic on nil pointer (close #4093)

This commit is contained in:
Andy Hsu 2023-04-09 14:06:04 +08:00
parent c77eebb035
commit c0a6beecea
2 changed files with 9 additions and 6 deletions

View File

@ -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
}

View File

@ -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
@ -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
@ -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