From 94755e221a5518c8029d4bfd85261d4a13677c2c Mon Sep 17 00:00:00 2001 From: link Date: Fri, 24 Feb 2023 14:20:30 +0800 Subject: [PATCH] Add judgment on mount points (#921) --- route/v1/samba.go | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/route/v1/samba.go b/route/v1/samba.go index 0792bb9..80deb82 100644 --- a/route/v1/samba.go +++ b/route/v1/samba.go @@ -207,12 +207,15 @@ func DeleteSambaConnections(c *gin.Context) { } baseHostPath := "/mnt/" + connection.Host for _, v := range mountPointList { - err := service.MyService.Connections().UnmountSmaba(baseHostPath + "/" + v) - if err != nil { - logger.Error("unmount smaba error", zap.Error(err), zap.Any("path", baseHostPath+"/"+v)) - c.JSON(common_err.SERVICE_ERROR, model.Result{Success: common_err.SERVICE_ERROR, Message: common_err.GetMsg(common_err.SERVICE_ERROR), Data: err.Error()}) - return + if service.IsMounted(baseHostPath + "/" + v) { + err := service.MyService.Connections().UnmountSmaba(baseHostPath + "/" + v) + if err != nil { + logger.Error("unmount smaba error", zap.Error(err), zap.Any("path", baseHostPath+"/"+v)) + c.JSON(common_err.SERVICE_ERROR, model.Result{Success: common_err.SERVICE_ERROR, Message: common_err.GetMsg(common_err.SERVICE_ERROR), Data: err.Error()}) + return + } } + } dir, _ := ioutil.ReadDir(connection.MountPoint) if len(dir) == 0 {