fix: check err before check upload

pull/1604/head
Noah Hsu 2022-08-29 14:18:43 +08:00
parent d267c43556
commit 97d4114e38
1 changed files with 6 additions and 6 deletions

View File

@ -20,12 +20,12 @@ var UploadTaskManager = task.NewTaskManager(3, func(tid *uint64) {
// putAsTask add as a put task and return immediately // putAsTask add as a put task and return immediately
func putAsTask(dstDirPath string, file model.FileStreamer) error { func putAsTask(dstDirPath string, file model.FileStreamer) error {
storage, dstDirActualPath, err := operations.GetStorageAndActualPath(dstDirPath) storage, dstDirActualPath, err := operations.GetStorageAndActualPath(dstDirPath)
if storage.Config().NoUpload {
return errors.WithStack(errs.UploadNotSupported)
}
if err != nil { if err != nil {
return errors.WithMessage(err, "failed get storage") return errors.WithMessage(err, "failed get storage")
} }
if storage.Config().NoUpload {
return errors.WithStack(errs.UploadNotSupported)
}
if file.NeedStore() { if file.NeedStore() {
tempFile, err := utils.CreateTempFile(file) tempFile, err := utils.CreateTempFile(file)
if err != nil { if err != nil {
@ -45,11 +45,11 @@ func putAsTask(dstDirPath string, file model.FileStreamer) error {
// putDirect put the file and return after finish // putDirect put the file and return after finish
func putDirectly(ctx context.Context, dstDirPath string, file model.FileStreamer) error { func putDirectly(ctx context.Context, dstDirPath string, file model.FileStreamer) error {
storage, dstDirActualPath, err := operations.GetStorageAndActualPath(dstDirPath) storage, dstDirActualPath, err := operations.GetStorageAndActualPath(dstDirPath)
if storage.Config().NoUpload {
return errors.WithStack(errs.UploadNotSupported)
}
if err != nil { if err != nil {
return errors.WithMessage(err, "failed get storage") return errors.WithMessage(err, "failed get storage")
} }
if storage.Config().NoUpload {
return errors.WithStack(errs.UploadNotSupported)
}
return operations.Put(ctx, storage, dstDirActualPath, file, nil) return operations.Put(ctx, storage, dstDirActualPath, file, nil)
} }