mirror of
https://github.com/halejohn/Cloudreve.git
synced 2026-01-26 09:34:57 +08:00
Feat: import file from existing outer folder
This commit is contained in:
@@ -285,6 +285,38 @@ func (fs *FileSystem) List(ctx context.Context, dirPath string, pathProcessor fu
|
||||
return fs.listObjects(ctx, parentPath, childFiles, childFolders, pathProcessor), nil
|
||||
}
|
||||
|
||||
// ListPhysical 列出存储策略中的外部目录
|
||||
// TODO:测试
|
||||
func (fs *FileSystem) ListPhysical(ctx context.Context, dirPath string) ([]Object, error) {
|
||||
if err := fs.DispatchHandler(); fs.Policy == nil || err != nil {
|
||||
return nil, ErrUnknownPolicyType
|
||||
}
|
||||
|
||||
// 存储策略不支持列取时,返回空结果
|
||||
if !fs.Policy.CanStructureBeListed() {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
// 列取路径
|
||||
objects, err := fs.Handler.List(ctx, dirPath, false)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var (
|
||||
folders []model.Folder
|
||||
)
|
||||
for _, object := range objects {
|
||||
if object.IsDir {
|
||||
folders = append(folders, model.Folder{
|
||||
Name: object.Name,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
return fs.listObjects(ctx, dirPath, nil, folders, nil), nil
|
||||
}
|
||||
|
||||
func (fs *FileSystem) listObjects(ctx context.Context, parent string, files []model.File, folders []model.Folder, pathProcessor func(string) string) []Object {
|
||||
// 分享文件的ID
|
||||
shareKey := ""
|
||||
|
||||
Reference in New Issue
Block a user