Skip to content

Commit

Permalink
fix: check err before check upload
Browse files Browse the repository at this point in the history
  • Loading branch information
xhofe committed Aug 29, 2022
1 parent d267c43 commit 97d4114
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions internal/fs/put.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ var UploadTaskManager = task.NewTaskManager(3, func(tid *uint64) {
// putAsTask add as a put task and return immediately
func putAsTask(dstDirPath string, file model.FileStreamer) error {
storage, dstDirActualPath, err := operations.GetStorageAndActualPath(dstDirPath)
if storage.Config().NoUpload {
return errors.WithStack(errs.UploadNotSupported)
}
if err != nil {
return errors.WithMessage(err, "failed get storage")
}
if storage.Config().NoUpload {
return errors.WithStack(errs.UploadNotSupported)
}
if file.NeedStore() {
tempFile, err := utils.CreateTempFile(file)
if err != nil {
Expand All @@ -45,11 +45,11 @@ 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 {
storage, dstDirActualPath, err := operations.GetStorageAndActualPath(dstDirPath)
if storage.Config().NoUpload {
return errors.WithStack(errs.UploadNotSupported)
}
if err != nil {
return errors.WithMessage(err, "failed get storage")
}
if storage.Config().NoUpload {
return errors.WithStack(errs.UploadNotSupported)
}
return operations.Put(ctx, storage, dstDirActualPath, file, nil)
}

0 comments on commit 97d4114

Please sign in to comment.