From 6ce95c60cdf59a7a63903235a12eaa80342dfb0a Mon Sep 17 00:00:00 2001 From: lzh <1625167628@qq.com> Date: Tue, 3 Jun 2025 14:10:33 +0800 Subject: [PATCH] =?UTF-8?q?=E8=87=AA=E5=8A=A8=E5=88=9B=E5=BB=BA=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E7=9B=AE=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- service/files.go | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) 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 {