mirror of https://github.com/Xhofe/alist
fix: check err before check upload
parent
d267c43556
commit
97d4114e38
|
@ -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)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue