mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-02-05 07:01:48 +01:00
✨ 云端支持多个数据仓库目录 Fix https://github.com/siyuan-note/siyuan/issues/5335
This commit is contained in:
parent
ce516e41fb
commit
114d85431f
4 changed files with 62 additions and 15 deletions
|
|
@ -40,7 +40,7 @@ require (
|
|||
github.com/qiniu/go-sdk/v7 v7.13.0
|
||||
github.com/radovskyb/watcher v1.0.7
|
||||
github.com/sabhiram/go-gitignore v0.0.0-20210923224102-525f6e181f06
|
||||
github.com/siyuan-note/dejavu v0.0.0-20220704130554-0dbba22cfd32
|
||||
github.com/siyuan-note/dejavu v0.0.0-20220704162819-bf588aabc1e0
|
||||
github.com/siyuan-note/encryption v0.0.0-20220612074546-f1dd94fe8676
|
||||
github.com/siyuan-note/eventbus v0.0.0-20220624162334-ca7c06dc771f
|
||||
github.com/siyuan-note/filelock v0.0.0-20220704090116-54dfb035283f
|
||||
|
|
|
|||
|
|
@ -421,8 +421,8 @@ github.com/shurcooL/httpfs v0.0.0-20190707220628-8d4bc4ba7749/go.mod h1:ZY1cvUeJ
|
|||
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
|
||||
github.com/shurcooL/vfsgen v0.0.0-20200824052919-0d455de96546/go.mod h1:TrYk7fJVaAttu97ZZKrO9UbRa8izdowaMIZcxYMbVaw=
|
||||
github.com/sirupsen/logrus v1.8.1/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0=
|
||||
github.com/siyuan-note/dejavu v0.0.0-20220704130554-0dbba22cfd32 h1:ZovFHkGpB/cbhO4XfoYUevesyrcXiZD55ixV5wOVxbw=
|
||||
github.com/siyuan-note/dejavu v0.0.0-20220704130554-0dbba22cfd32/go.mod h1:ral+X0pNW6nSQVvIcxllUXSczCaY4UOCT2iGlO4YNg0=
|
||||
github.com/siyuan-note/dejavu v0.0.0-20220704162819-bf588aabc1e0 h1:MW12dGaf0QgsNjIaBQicP3KYmBwrJPX26zp/CmurThY=
|
||||
github.com/siyuan-note/dejavu v0.0.0-20220704162819-bf588aabc1e0/go.mod h1:ral+X0pNW6nSQVvIcxllUXSczCaY4UOCT2iGlO4YNg0=
|
||||
github.com/siyuan-note/encryption v0.0.0-20220612074546-f1dd94fe8676 h1:QB9TjJQFhXhZ6dAtPpY02DlzHAQm1C+WqZq6OadG8mI=
|
||||
github.com/siyuan-note/encryption v0.0.0-20220612074546-f1dd94fe8676/go.mod h1:H8fyqqAbp9XreANjeSbc72zEdFfKTXYN34tc1TjZwtw=
|
||||
github.com/siyuan-note/eventbus v0.0.0-20220624162334-ca7c06dc771f h1:JMobMNZ7AqaKKyEK+WeWFhix/2TDQXgPZDajU00IybU=
|
||||
|
|
|
|||
|
|
@ -272,13 +272,9 @@ func syncRepo(boot, exit, byHand bool) {
|
|||
}
|
||||
|
||||
start := time.Now()
|
||||
cloudInfo := &dejavu.CloudInfo{
|
||||
Dir: "main",
|
||||
UserID: Conf.User.UserId,
|
||||
Token: Conf.User.UserToken,
|
||||
LimitSize: int64(Conf.User.UserSiYuanRepoSize - Conf.User.UserSiYuanAssetSize),
|
||||
ProxyURL: Conf.System.NetworkProxy.String(),
|
||||
Server: util.AliyunServer,
|
||||
cloudInfo, err := buildCloudInfo()
|
||||
if nil != err {
|
||||
return
|
||||
}
|
||||
syncContext := map[string]interface{}{CtxPushMsg: CtxPushMsgToStatusBar}
|
||||
|
||||
|
|
@ -471,3 +467,20 @@ func contextPushMsg(context map[string]interface{}, msg string) {
|
|||
util.PushEndlessProgress(msg)
|
||||
}
|
||||
}
|
||||
|
||||
func buildCloudInfo() (ret *dejavu.CloudInfo, err error) {
|
||||
if nil == Conf.User || "" == Conf.Sync.CloudName {
|
||||
err = errors.New("invalid cloud info")
|
||||
return
|
||||
}
|
||||
|
||||
ret = &dejavu.CloudInfo{
|
||||
Dir: Conf.Sync.CloudName,
|
||||
UserID: Conf.User.UserId,
|
||||
Token: Conf.User.UserToken,
|
||||
LimitSize: int64(Conf.User.UserSiYuanRepoSize - Conf.User.UserSiYuanAssetSize),
|
||||
ProxyURL: Conf.System.NetworkProxy.String(),
|
||||
Server: util.AliyunServer,
|
||||
}
|
||||
return
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,6 +35,7 @@ import (
|
|||
"github.com/88250/gulu"
|
||||
"github.com/dustin/go-humanize"
|
||||
gitignore "github.com/sabhiram/go-gitignore"
|
||||
"github.com/siyuan-note/dejavu"
|
||||
"github.com/siyuan-note/encryption"
|
||||
"github.com/siyuan-note/filelock"
|
||||
"github.com/siyuan-note/siyuan/kernel/cache"
|
||||
|
|
@ -1150,9 +1151,16 @@ func CreateCloudSyncDir(name string) (err error) {
|
|||
return errors.New(Conf.Language(37))
|
||||
}
|
||||
|
||||
err = createCloudSyncDirOSS(name)
|
||||
if nil != err {
|
||||
return
|
||||
if Conf.Sync.UseDataRepo {
|
||||
var cloudInfo *dejavu.CloudInfo
|
||||
cloudInfo, err = buildCloudInfo()
|
||||
if nil != err {
|
||||
return
|
||||
}
|
||||
|
||||
err = dejavu.CreateCloudRepo(name, cloudInfo)
|
||||
} else {
|
||||
err = createCloudSyncDirOSS(name)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
|
@ -1165,7 +1173,18 @@ func RemoveCloudSyncDir(name string) (err error) {
|
|||
return
|
||||
}
|
||||
|
||||
err = removeCloudDirPath("sync/" + name)
|
||||
if Conf.Sync.UseDataRepo {
|
||||
var cloudInfo *dejavu.CloudInfo
|
||||
cloudInfo, err = buildCloudInfo()
|
||||
if nil != err {
|
||||
return
|
||||
}
|
||||
|
||||
err = dejavu.RemoveCloudRepo(name, cloudInfo)
|
||||
} else {
|
||||
err = removeCloudDirPath("sync/" + name)
|
||||
}
|
||||
|
||||
if nil != err {
|
||||
return
|
||||
}
|
||||
|
|
@ -1179,8 +1198,23 @@ func RemoveCloudSyncDir(name string) (err error) {
|
|||
|
||||
func ListCloudSyncDir() (syncDirs []*Sync, hSize string, err error) {
|
||||
syncDirs = []*Sync{}
|
||||
var dirs []map[string]interface{}
|
||||
var size int64
|
||||
if Conf.Sync.UseDataRepo {
|
||||
var cloudInfo *dejavu.CloudInfo
|
||||
cloudInfo, err = buildCloudInfo()
|
||||
if nil != err {
|
||||
return
|
||||
}
|
||||
|
||||
dirs, size, err = dejavu.GetCloudRepos(cloudInfo)
|
||||
} else {
|
||||
dirs, size, err = listCloudSyncDirOSS()
|
||||
}
|
||||
if nil != err {
|
||||
return
|
||||
}
|
||||
|
||||
dirs, size, err := listCloudSyncDirOSS()
|
||||
for _, d := range dirs {
|
||||
dirSize := int64(d["size"].(float64))
|
||||
syncDirs = append(syncDirs, &Sync{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue