diff --git a/go.mod b/go.mod index f7ff80ea4..7581fe8df 100644 --- a/go.mod +++ b/go.mod @@ -32,7 +32,6 @@ require ( github.com/patrickmn/go-cache v2.1.0+incompatible github.com/pkg/errors v0.9.1 github.com/robfig/cron v1.2.0 - github.com/samber/lo v1.37.0 github.com/satori/go.uuid v1.2.0 github.com/shirou/gopsutil/v3 v3.22.11 github.com/sirupsen/logrus v1.9.0 @@ -110,7 +109,6 @@ require ( github.com/yusufpapurcu/wmi v1.2.2 // indirect go.uber.org/atomic v1.7.0 // indirect go.uber.org/multierr v1.6.0 // indirect - golang.org/x/exp v0.0.0-20220303212507-bbda1eaf7a17 // indirect golang.org/x/image v0.0.0-20191009234506-e7c1f5e7dbb8 // indirect golang.org/x/net v0.5.0 // indirect golang.org/x/sys v0.4.0 // indirect diff --git a/go.sum b/go.sum index 3b6a01f77..372f869d6 100644 --- a/go.sum +++ b/go.sum @@ -234,8 +234,6 @@ github.com/robfig/cron v1.2.0/go.mod h1:JGuDeoQd7Z6yL4zQhZ3OPEVHB7fL6Ka6skscFHfm github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc= github.com/rogpeppe/go-internal v1.8.0 h1:FCbCCtXNOY3UtUuHUYaghJg4y7Fd14rXifAYUAtL9R8= github.com/rogpeppe/go-internal v1.8.0/go.mod h1:WmiCO8CzOY8rg0OYDC4/i/2WRWAB6poM+XZ2dLUbcbE= -github.com/samber/lo v1.37.0 h1:XjVcB8g6tgUp8rsPsJ2CvhClfImrpL04YpQHXeHPhRw= -github.com/samber/lo v1.37.0/go.mod h1:9vaz2O4o8oOnK23pd2TrXufcbdbJIa3b6cstBWKpopA= github.com/satori/go.uuid v1.2.0 h1:0uYX9dsZ2yD7q2RtLRtPSdGDWzjeM3TbMJP9utgA0ww= github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0= github.com/shirou/gopsutil/v3 v3.22.11 h1:kxsPKS+Eeo+VnEQ2XCaGJepeP6KY53QoRTETx3+1ndM= @@ -296,8 +294,6 @@ golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97/go.mod h1:GvvjBRRGRdwPK5y golang.org/x/crypto v0.0.0-20211215153901-e495a2d5b3d3/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/crypto v0.5.0 h1:U/0M97KRkSFvyD/3FSmdP5W5swImpNgle/EHFhOsQPE= golang.org/x/crypto v0.5.0/go.mod h1:NK/OQwhpMQP3MwtdjgLlYHnH9ebylxKWv3e0fK+mkQU= -golang.org/x/exp v0.0.0-20220303212507-bbda1eaf7a17 h1:3MTrJm4PyNL9NBqvYDSj3DHl46qQakyfqfWo4jgfaEM= -golang.org/x/exp v0.0.0-20220303212507-bbda1eaf7a17/go.mod h1:lgLbSvA5ygNOMpwM/9anMpWVlVJ7Z+cHWq/eFuinpGE= golang.org/x/image v0.0.0-20191009234506-e7c1f5e7dbb8 h1:hVwzHzIUGRjiF7EcUjqNxk3NCfkPxbDKRdnNE1Rpg0U= golang.org/x/image v0.0.0-20191009234506-e7c1f5e7dbb8/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= diff --git a/pkg/utils/httper/drive.go b/pkg/utils/httper/drive.go index 5693d28e8..cdf49e26c 100644 --- a/pkg/utils/httper/drive.go +++ b/pkg/utils/httper/drive.go @@ -7,7 +7,9 @@ import ( "net/http" "time" + "github.com/IceWhaleTech/CasaOS-Common/utils/logger" "github.com/go-resty/resty/v2" + "go.uber.org/zap" ) type MountList struct { @@ -82,6 +84,7 @@ func Mount(mountPoint string, fs string) error { if res.StatusCode() != 200 { return fmt.Errorf("mount failed") } + logger.Info("mount then", zap.Any("res", res.Body())) return nil } func Unmount(mountPoint string) error { @@ -94,6 +97,7 @@ func Unmount(mountPoint string) error { if res.StatusCode() != 200 { return fmt.Errorf("unmount failed") } + logger.Info("unmount then", zap.Any("res", res.Body())) return nil } @@ -111,6 +115,7 @@ func CreateConfig(data map[string]string, name, t string) error { if res.StatusCode() != 200 { return fmt.Errorf("create config failed") } + logger.Info("create config then", zap.Any("res", res.Body())) return nil } diff --git a/service/storage.go b/service/storage.go index cf347f186..01fd45ee8 100644 --- a/service/storage.go +++ b/service/storage.go @@ -3,8 +3,10 @@ package service import ( "io/ioutil" + "github.com/IceWhaleTech/CasaOS-Common/utils/logger" "github.com/IceWhaleTech/CasaOS/pkg/utils/file" "github.com/IceWhaleTech/CasaOS/pkg/utils/httper" + "go.uber.org/zap" ) type StorageService interface { @@ -23,8 +25,7 @@ type storageStruct struct { func (s *storageStruct) MountStorage(mountPoint, fs string) error { file.IsNotExistMkDir(mountPoint) - httper.Mount(mountPoint, fs) - return nil + return httper.Mount(mountPoint, fs) } func (s *storageStruct) UnmountStorage(mountPoint string) error { err := httper.Unmount(mountPoint) @@ -57,7 +58,7 @@ func (s *storageStruct) CheckAndMountByName(name string) error { } } if !isMount { - MyService.Storage().MountStorage(mountPoint, name+":") + return MyService.Storage().MountStorage(mountPoint, name+":") } return nil } @@ -66,10 +67,12 @@ func (s *storageStruct) CheckAndMountAll() error { if err != nil { return err } + logger.Info("when CheckAndMountAll storages", zap.Any("storages", storages)) section, err := httper.GetAllConfigName() if err != nil { return err } + logger.Info("when CheckAndMountAll section", zap.Any("section", section)) for _, v := range section.Remotes { currentRemote, _ := httper.GetConfigByName(v) mountPoint := currentRemote["mount_point"] @@ -84,7 +87,11 @@ func (s *storageStruct) CheckAndMountAll() error { } } if !isMount { - return MyService.Storage().MountStorage(mountPoint, v+":") + logger.Info("when CheckAndMountAll MountStorage", zap.String("mountPoint", mountPoint), zap.String("fs", v)) + err := MyService.Storage().MountStorage(mountPoint, v+":") + if err != nil { + logger.Error("when CheckAndMountAll then", zap.String("mountPoint", mountPoint), zap.String("fs", v), zap.Error(err)) + } } } return nil