Fix sharing failure issue (#884)

This commit is contained in:
link 2023-02-10 17:27:13 +08:00 committed by GitHub
parent c8b6a1c228
commit 7b07f22685
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 11 additions and 14 deletions

View File

@ -17,12 +17,14 @@ type MountList struct {
MountPoint string `json:"MountPoint"` MountPoint string `json:"MountPoint"`
Fs string `json:"Fs"` Fs string `json:"Fs"`
Icon string `json:"Icon"` Icon string `json:"Icon"`
Name string `json:"Name"`
} `json:"mountPoints"` } `json:"mountPoints"`
} }
type MountPoint struct { type MountPoint struct {
MountPoint string `json:"mount_point"` MountPoint string `json:"mount_point"`
Fs string `json:"fs"` Fs string `json:"fs"`
Icon string `json:"icon"` Icon string `json:"icon"`
Name string `json:"name"`
} }
type MountResult struct { type MountResult struct {
Error string `json:"error"` Error string `json:"error"`
@ -77,6 +79,7 @@ func Mount(mountPoint string, fs string) error {
res, err := NewRestyClient().R().SetFormData(map[string]string{ res, err := NewRestyClient().R().SetFormData(map[string]string{
"mountPoint": mountPoint, "mountPoint": mountPoint,
"fs": fs, "fs": fs,
"mountOpt": `{"AllowOther": true}`,
}).Post("/mount/mount") }).Post("/mount/mount")
if err != nil { if err != nil {
return err return err

View File

@ -1,13 +1,13 @@
package v1 package v1
import ( import (
"strconv"
"strings" "strings"
"time" "time"
"github.com/IceWhaleTech/CasaOS-Common/utils/logger" "github.com/IceWhaleTech/CasaOS-Common/utils/logger"
"github.com/IceWhaleTech/CasaOS/drivers/dropbox" "github.com/IceWhaleTech/CasaOS/drivers/dropbox"
"github.com/IceWhaleTech/CasaOS/drivers/google_drive" "github.com/IceWhaleTech/CasaOS/drivers/google_drive"
fileutil "github.com/IceWhaleTech/CasaOS/pkg/utils/file"
"github.com/IceWhaleTech/CasaOS/service" "github.com/IceWhaleTech/CasaOS/service"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
"go.uber.org/zap" "go.uber.org/zap"
@ -82,13 +82,10 @@ func GetRecoverStorage(c *gin.Context) {
a := strings.Split(username, "@") a := strings.Split(username, "@")
username = a[0] username = a[0]
} }
username = fileutil.NameAccumulation(username, "/mnt")
dataMap, _ := service.MyService.Storage().GetConfigByName(username) //username = fileutil.NameAccumulation(username, "/mnt")
if len(dataMap) > 0 { username += "_google_drive_" + strconv.FormatInt(time.Now().Unix(), 10)
service.MyService.Storage().UnmountStorage("/mnt/" + username)
service.MyService.Storage().DeleteConfigByName(username)
}
dmap["client_id"] = add.ClientID dmap["client_id"] = add.ClientID
dmap["client_secret"] = add.ClientSecret dmap["client_secret"] = add.ClientSecret
dmap["scope"] = "drive" dmap["scope"] = "drive"
@ -161,13 +158,7 @@ func GetRecoverStorage(c *gin.Context) {
a := strings.Split(username, "@") a := strings.Split(username, "@")
username = a[0] username = a[0]
} }
username = fileutil.NameAccumulation(username, "/mnt") username += "_dropbox_" + strconv.FormatInt(time.Now().Unix(), 10)
dataMap, _ := service.MyService.Storage().GetConfigByName(username)
if len(dataMap) > 0 {
service.MyService.Storage().UnmountStorage("/mnt/" + username)
service.MyService.Storage().DeleteConfigByName(username)
}
dmap["client_id"] = add.AppKey dmap["client_id"] = add.AppKey
dmap["client_secret"] = add.AppSecret dmap["client_secret"] = add.AppSecret

View File

@ -52,6 +52,7 @@ func ListStorages(c *gin.Context) {
if dataMap["type"] == "dropbox" { if dataMap["type"] == "dropbox" {
r.MountPoints[i].Icon = dropbox.ICONURL r.MountPoints[i].Icon = dropbox.ICONURL
} }
r.MountPoints[i].Name = dataMap["username"]
} }
list := []httper.MountPoint{} list := []httper.MountPoint{}
@ -60,6 +61,7 @@ func ListStorages(c *gin.Context) {
Fs: v.Fs, Fs: v.Fs,
Icon: v.Icon, Icon: v.Icon,
MountPoint: v.MountPoint, MountPoint: v.MountPoint,
Name: v.Name,
}) })
} }

View File

@ -97,6 +97,7 @@ func (s *storageStruct) CheckAndMountAll() error {
} }
return nil return nil
} }
func (s *storageStruct) GetConfigByName(name string) (map[string]string, error) { func (s *storageStruct) GetConfigByName(name string) (map[string]string, error) {
return httper.GetConfigByName(name) return httper.GetConfigByName(name)
} }