mirror of
https://github.com/halejohn/Cloudreve.git
synced 2026-01-26 09:34:57 +08:00
Fix: upload was marked canceled when small file uploaded
This commit is contained in:
@@ -2,9 +2,7 @@ package filesystem
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
model "github.com/HFO4/cloudreve/models"
|
||||
"github.com/HFO4/cloudreve/pkg/serializer"
|
||||
"github.com/HFO4/cloudreve/pkg/util"
|
||||
"io"
|
||||
)
|
||||
@@ -37,9 +35,9 @@ func (fs *FileSystem) AddFile(ctx context.Context, parent *model.Folder) (*model
|
||||
return &newFile, nil
|
||||
}
|
||||
|
||||
// Download 处理下载文件请求,path为虚拟路径
|
||||
// GetContent 获取文件内容,path为虚拟路径
|
||||
// TODO:测试
|
||||
func (fs *FileSystem) Download(ctx context.Context, path string) (io.ReadCloser, error) {
|
||||
func (fs *FileSystem) GetContent(ctx context.Context, path string) (io.ReadSeeker, error) {
|
||||
// 触发`下载前`钩子
|
||||
err := fs.Trigger(ctx, fs.BeforeFileDownload)
|
||||
if err != nil {
|
||||
@@ -52,6 +50,7 @@ func (fs *FileSystem) Download(ctx context.Context, path string) (io.ReadCloser,
|
||||
if !exist {
|
||||
return nil, ErrObjectNotExist
|
||||
}
|
||||
fs.Target = &file
|
||||
|
||||
// 将当前存储策略重设为文件使用的
|
||||
fs.Policy = file.GetPolicy()
|
||||
@@ -60,5 +59,11 @@ func (fs *FileSystem) Download(ctx context.Context, path string) (io.ReadCloser,
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return nil, serializer.NewError(serializer.CodeEncryptError, "人都的", errors.New("不是人都的"))
|
||||
// 获取文件流
|
||||
rs, err := fs.Handler.Get(ctx, file.SourceName)
|
||||
if err != nil {
|
||||
return nil, ErrIO.WithError(err)
|
||||
}
|
||||
|
||||
return rs, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user