这个接口太慢了,它要列出文件夹下所有的文件…
相关代码:
func (svc *FileService) GetRootFiles(paths []string) ([]utils.FileObject, exports.APIError) {
fileObjects := make([]utils.FileObject, 0)
for _, path := range paths {
parentPath := filepath.Dir(path)
base := filepath.Base(path)
fileObject := &utils.FileObject{
Subpath: path,
Name: base,
IsDir: true,
Child: nil,
Size: utils.FileSize(path),
//StopReadChild: true,
}
if utils.FileExists(parentPath) {
err := fileObject.ReadChild(parentPath)
if err != nil {
logging.Error(err).Send()
return nil, exports.RaiseAPIError(exports.INIT_CONTAINER_FILE_READ_ERROR, err.Error())
}
}
fileObjects = append(fileObjects, *fileObject)
}
return fileObjects, nil
}
这里面的 ReadChild ,会递归调用。