修复从OSS导入外部数据时,多级目录偶尔会被当做文件处理的问题

pull/1532/head
戚辅光 3 years ago
parent 6b63195d28
commit c699c50c7d

@ -171,14 +171,25 @@ func (handler *Driver) List(ctx context.Context, base string, recursive bool) ([
if err != nil { if err != nil {
continue continue
} }
res = append(res, response.Object{ // oss sdk返回的数据在多级目录的情况下偶尔有问题有些目录被当做了文件处理
Name: path.Base(object.Key), if strings.HasSuffix(object.Key, "/") {
Source: object.Key, res = append(res, response.Object{
RelativePath: filepath.ToSlash(rel), Name: path.Base(object.Key),
Size: uint64(object.Size), RelativePath: filepath.ToSlash(rel),
IsDir: false, Size: 0,
LastModify: object.LastModified, IsDir: true,
}) LastModify: time.Now(),
})
} else {
res = append(res, response.Object{
Name: path.Base(object.Key),
Source: object.Key,
RelativePath: filepath.ToSlash(rel),
Size: uint64(object.Size),
IsDir: false,
LastModify: object.LastModified,
})
}
} }
return res, nil return res, nil

Loading…
Cancel
Save