Skip to content

Commit

Permalink
Fix sharing failure issue (#884)
Browse files Browse the repository at this point in the history
  • Loading branch information
LinkLeong authored Feb 10, 2023
1 parent c8b6a1c commit 7b07f22
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 14 deletions.
3 changes: 3 additions & 0 deletions pkg/utils/httper/drive.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down Expand Up @@ -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
Expand Down
19 changes: 5 additions & 14 deletions route/v1/recover.go
Original file line number Diff line number Diff line change
@@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions route/v1/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{}

Expand All @@ -60,6 +61,7 @@ func ListStorages(c *gin.Context) {
Fs: v.Fs,
Icon: v.Icon,
MountPoint: v.MountPoint,
Name: v.Name,
})
}

Expand Down
1 change: 1 addition & 0 deletions service/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down

0 comments on commit 7b07f22

Please sign in to comment.