feat: file proxy handle

This commit is contained in:
Noah Hsu
2022-06-28 21:58:46 +08:00
parent d1efec4539
commit 96380a50da
11 changed files with 167 additions and 90 deletions

View File

@ -85,7 +85,7 @@ func copyFileBetween2Accounts(tsk *task.Task[uint64], srcAccount, dstAccount dri
if err != nil {
return errors.WithMessagef(err, "failed get src [%s] file", srcFilePath)
}
link, err := operations.Link(tsk.Ctx, srcAccount, srcFilePath, model.LinkArgs{})
link, _, err := operations.Link(tsk.Ctx, srcAccount, srcFilePath, model.LinkArgs{})
if err != nil {
return errors.WithMessagef(err, "failed get [%s] link", srcFilePath)
}

View File

@ -30,13 +30,13 @@ func Get(ctx context.Context, path string) (model.Obj, error) {
return res, nil
}
func Link(ctx context.Context, path string, args model.LinkArgs) (*model.Link, error) {
res, err := link(ctx, path, args)
func Link(ctx context.Context, path string, args model.LinkArgs) (*model.Link, model.Obj, error) {
res, file, err := link(ctx, path, args)
if err != nil {
log.Errorf("failed link %s: %+v", path, err)
return nil, err
return nil, nil, err
}
return res, nil
return res, file, nil
}
func MakeDir(ctx context.Context, path string) error {

View File

@ -7,10 +7,10 @@ import (
"github.com/pkg/errors"
)
func link(ctx context.Context, path string, args model.LinkArgs) (*model.Link, error) {
func link(ctx context.Context, path string, args model.LinkArgs) (*model.Link, model.Obj, error) {
account, actualPath, err := operations.GetAccountAndActualPath(path)
if err != nil {
return nil, errors.WithMessage(err, "failed get account")
return nil, nil, errors.WithMessage(err, "failed get account")
}
return operations.Link(ctx, account, actualPath, args)
}