From 3457b99df6b9f4de21cf3c5054fd6268e82ab231 Mon Sep 17 00:00:00 2001 From: zhengkunwang223 <31820853+zhengkunwang223@users.noreply.github.com> Date: Fri, 31 Mar 2023 12:16:14 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=A7=A3=E5=86=B3=20nexus=20=E5=AE=89?= =?UTF-8?q?=E8=A3=85=E5=A4=B1=E8=B4=A5=E7=9A=84=E9=97=AE=E9=A2=98=20(#461)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/app/service/app.go | 3 +++ backend/app/service/app_utils.go | 11 +++++++++++ backend/utils/files/file_op.go | 4 ++++ 3 files changed, 18 insertions(+) diff --git a/backend/app/service/app.go b/backend/app/service/app.go index 2a4fc3e4c..c75c104d5 100644 --- a/backend/app/service/app.go +++ b/backend/app/service/app.go @@ -257,6 +257,9 @@ func (a AppService) Install(ctx context.Context, req request.AppInstallCreate) ( if err := createLink(ctx, app, &appInstall, req.Params); err != nil { return nil, err } + if err := upAppPre(app, appInstall); err != nil { + return nil, err + } go upApp(appInstall.GetComposePath(), appInstall) go updateToolApp(appInstall) return &appInstall, nil diff --git a/backend/app/service/app_utils.go b/backend/app/service/app_utils.go index 181974030..f193cb147 100644 --- a/backend/app/service/app_utils.go +++ b/backend/app/service/app_utils.go @@ -339,6 +339,17 @@ func copyAppData(key, version, installName string, params map[string]interface{} return } +// 处理文件夹权限等问题 +func upAppPre(app model.App, appInstall model.AppInstall) error { + if app.Key == "nexus" { + dataPath := path.Join(appInstall.GetPath(), "data") + if err := files.NewFileOp().Chown(dataPath, 200, 0); err != nil { + return err + } + } + return nil +} + func upApp(composeFilePath string, appInstall model.AppInstall) { out, err := compose.Up(composeFilePath) if err != nil { diff --git a/backend/utils/files/file_op.go b/backend/utils/files/file_op.go index ae450f8d9..cb3b18564 100644 --- a/backend/utils/files/file_op.go +++ b/backend/utils/files/file_op.go @@ -106,6 +106,10 @@ func (f FileOp) Chmod(dst string, mode fs.FileMode) error { return f.Fs.Chmod(dst, mode) } +func (f FileOp) Chown(dst string, uid int, gid int) error { + return f.Fs.Chown(dst, uid, gid) +} + func (f FileOp) Rename(oldName string, newName string) error { return f.Fs.Rename(oldName, newName) }