... | ... | @@ -3,3 +3,33 @@ GET https://103.44.253.115/ai-arts/api/v1/projects/1134/code-lab/1145811/runs/de |
|
|
|
|
|
这个接口太慢了,它要列出文件夹下所有的文件…
|
|
|
|
|
|
相关代码:
|
|
|
```golang
|
|
|
|
|
|
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 ,会递归调用。 |
|
|
\ No newline at end of file |