Fix sharing failure issue (#884)
This commit is contained in:
parent
c8b6a1c228
commit
7b07f22685
4 changed files with 11 additions and 14 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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,
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue