diff --git a/pkg/utils/httper/drive.go b/pkg/utils/httper/drive.go index 28b4c1ba0..0f2568101 100644 --- a/pkg/utils/httper/drive.go +++ b/pkg/utils/httper/drive.go @@ -17,12 +17,14 @@ type MountList struct { MountPoint string `json:"MountPoint"` Fs string `json:"Fs"` Icon string `json:"Icon"` + Name string `json:"Name"` } `json:"mountPoints"` } type MountPoint struct { MountPoint string `json:"mount_point"` Fs string `json:"fs"` Icon string `json:"icon"` + Name string `json:"name"` } type MountResult struct { Error string `json:"error"` @@ -77,6 +79,7 @@ func Mount(mountPoint string, fs string) error { res, err := NewRestyClient().R().SetFormData(map[string]string{ "mountPoint": mountPoint, "fs": fs, + "mountOpt": `{"AllowOther": true}`, }).Post("/mount/mount") if err != nil { return err diff --git a/route/v1/recover.go b/route/v1/recover.go index 02f96a300..a52982520 100644 --- a/route/v1/recover.go +++ b/route/v1/recover.go @@ -1,13 +1,13 @@ package v1 import ( + "strconv" "strings" "time" "github.com/IceWhaleTech/CasaOS-Common/utils/logger" "github.com/IceWhaleTech/CasaOS/drivers/dropbox" "github.com/IceWhaleTech/CasaOS/drivers/google_drive" - fileutil "github.com/IceWhaleTech/CasaOS/pkg/utils/file" "github.com/IceWhaleTech/CasaOS/service" "github.com/gin-gonic/gin" "go.uber.org/zap" @@ -82,13 +82,10 @@ func GetRecoverStorage(c *gin.Context) { a := strings.Split(username, "@") username = a[0] } - username = fileutil.NameAccumulation(username, "/mnt") - dataMap, _ := service.MyService.Storage().GetConfigByName(username) - if len(dataMap) > 0 { - service.MyService.Storage().UnmountStorage("/mnt/" + username) - service.MyService.Storage().DeleteConfigByName(username) - } + //username = fileutil.NameAccumulation(username, "/mnt") + username += "_google_drive_" + strconv.FormatInt(time.Now().Unix(), 10) + dmap["client_id"] = add.ClientID dmap["client_secret"] = add.ClientSecret dmap["scope"] = "drive" @@ -161,13 +158,7 @@ func GetRecoverStorage(c *gin.Context) { a := strings.Split(username, "@") username = a[0] } - username = fileutil.NameAccumulation(username, "/mnt") - dataMap, _ := service.MyService.Storage().GetConfigByName(username) - if len(dataMap) > 0 { - - service.MyService.Storage().UnmountStorage("/mnt/" + username) - service.MyService.Storage().DeleteConfigByName(username) - } + username += "_dropbox_" + strconv.FormatInt(time.Now().Unix(), 10) dmap["client_id"] = add.AppKey dmap["client_secret"] = add.AppSecret diff --git a/route/v1/storage.go b/route/v1/storage.go index 334b425ba..0c072350a 100644 --- a/route/v1/storage.go +++ b/route/v1/storage.go @@ -52,6 +52,7 @@ func ListStorages(c *gin.Context) { if dataMap["type"] == "dropbox" { r.MountPoints[i].Icon = dropbox.ICONURL } + r.MountPoints[i].Name = dataMap["username"] } list := []httper.MountPoint{} @@ -60,6 +61,7 @@ func ListStorages(c *gin.Context) { Fs: v.Fs, Icon: v.Icon, MountPoint: v.MountPoint, + Name: v.Name, }) } diff --git a/service/storage.go b/service/storage.go index 14e57ceef..a13711e43 100644 --- a/service/storage.go +++ b/service/storage.go @@ -97,6 +97,7 @@ func (s *storageStruct) CheckAndMountAll() error { } return nil } + func (s *storageStruct) GetConfigByName(name string) (map[string]string, error) { return httper.GetConfigByName(name) }