自动创建用户目录

This commit is contained in:
lzh 2025-06-03 14:10:33 +08:00
parent ae389aebe8
commit 6ce95c60cd

View File

@ -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 {