chore: rename account to storage

This commit is contained in:
Noah Hsu
2022-07-10 14:45:39 +08:00
parent efa20cc7bd
commit fc1204c914
31 changed files with 548 additions and 548 deletions

View File

@ -18,12 +18,12 @@ var UploadTaskManager = task.NewTaskManager[uint64](3, func(tid *uint64) {
// putAsTask add as a put task and return immediately
func putAsTask(dstDirPath string, file model.FileStreamer) error {
account, dstDirActualPath, err := operations.GetAccountAndActualPath(dstDirPath)
if account.Config().NoUpload {
storage, dstDirActualPath, err := operations.GetStorageAndActualPath(dstDirPath)
if storage.Config().NoUpload {
return errors.WithStack(errs.UploadNotSupported)
}
if err != nil {
return errors.WithMessage(err, "failed get account")
return errors.WithMessage(err, "failed get storage")
}
if file.NeedStore() {
tempFile, err := utils.CreateTempFile(file)
@ -33,9 +33,9 @@ func putAsTask(dstDirPath string, file model.FileStreamer) error {
file.SetReadCloser(tempFile)
}
UploadTaskManager.Submit(task.WithCancelCtx(&task.Task[uint64]{
Name: fmt.Sprintf("upload %s to [%s](%s)", file.GetName(), account.GetAccount().VirtualPath, dstDirActualPath),
Name: fmt.Sprintf("upload %s to [%s](%s)", file.GetName(), storage.GetStorage().VirtualPath, dstDirActualPath),
Func: func(task *task.Task[uint64]) error {
return operations.Put(task.Ctx, account, dstDirActualPath, file, nil)
return operations.Put(task.Ctx, storage, dstDirActualPath, file, nil)
},
}))
return nil
@ -43,12 +43,12 @@ func putAsTask(dstDirPath string, file model.FileStreamer) error {
// putDirect put the file and return after finish
func putDirectly(ctx context.Context, dstDirPath string, file model.FileStreamer) error {
account, dstDirActualPath, err := operations.GetAccountAndActualPath(dstDirPath)
if account.Config().NoUpload {
storage, dstDirActualPath, err := operations.GetStorageAndActualPath(dstDirPath)
if storage.Config().NoUpload {
return errors.WithStack(errs.UploadNotSupported)
}
if err != nil {
return errors.WithMessage(err, "failed get account")
return errors.WithMessage(err, "failed get storage")
}
return operations.Put(ctx, account, dstDirActualPath, file, nil)
return operations.Put(ctx, storage, dstDirActualPath, file, nil)
}