Modify: add recursive options for list method

Test: local.List
This commit is contained in:
HFO4
2020-04-27 10:31:34 +08:00
parent 26d4d34837
commit 36e5b31f73
10 changed files with 42 additions and 14 deletions

View File

@@ -24,7 +24,7 @@ type Driver struct {
}
// List 递归列取给定物理路径下所有文件
func (handler Driver) List(ctx context.Context, path string) ([]response.Object, error) {
func (handler Driver) List(ctx context.Context, path string, recursive bool) ([]response.Object, error) {
var res []response.Object
// 取得起始路径
@@ -58,6 +58,11 @@ func (handler Driver) List(ctx context.Context, path string) ([]response.Object,
LastModify: info.ModTime(),
})
// 如果非递归,则不步入目录
if !recursive && info.IsDir() {
return filepath.SkipDir
}
return nil
})