diff --git a/service/files.go b/service/files.go index 1c0cf0b..c12757f 100644 --- a/service/files.go +++ b/service/files.go @@ -452,12 +452,17 @@ func newFileDownloadWriter(stream filesApi.File_DirDownloadServer) *fileDownload } } -func getFs(UserSpacePath string) afero.Fs { +func getFs(userSpacePath string) afero.Fs { bashAbs, _ := filepath.Abs(BASE_PATH) - if !strings.HasPrefix(UserSpacePath, "/") { - UserSpacePath = "/" + UserSpacePath + + if !strings.HasPrefix(userSpacePath, "/") { + userSpacePath = "/" + userSpacePath } - return afero.NewBasePathFs(afero.NewOsFs(), bashAbs+UserSpacePath) + _, err := os.Stat(bashAbs + userSpacePath) + if err != nil { + os.MkdirAll(bashAbs+userSpacePath, os.ModeDir) + } + return afero.NewBasePathFs(afero.NewOsFs(), bashAbs+userSpacePath) } func checkParent(src, dst string) error {