mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-20 08:30:12 +01:00
♻️ 重构数据仓库同步 Fix https://github.com/siyuan-note/siyuan/issues/6427
This commit is contained in:
parent
ea89f6a78a
commit
dc1afe1a46
4 changed files with 11 additions and 9 deletions
|
|
@ -36,7 +36,7 @@ require (
|
||||||
github.com/panjf2000/ants/v2 v2.6.0
|
github.com/panjf2000/ants/v2 v2.6.0
|
||||||
github.com/patrickmn/go-cache v2.1.0+incompatible
|
github.com/patrickmn/go-cache v2.1.0+incompatible
|
||||||
github.com/radovskyb/watcher v1.0.7
|
github.com/radovskyb/watcher v1.0.7
|
||||||
github.com/siyuan-note/dejavu v0.0.0-20221031154617-cd9466fb0785
|
github.com/siyuan-note/dejavu v0.0.0-20221031160243-9bedc511961f
|
||||||
github.com/siyuan-note/encryption v0.0.0-20220713091850-5ecd92177b75
|
github.com/siyuan-note/encryption v0.0.0-20220713091850-5ecd92177b75
|
||||||
github.com/siyuan-note/eventbus v0.0.0-20220916025349-3ac6e75522da
|
github.com/siyuan-note/eventbus v0.0.0-20220916025349-3ac6e75522da
|
||||||
github.com/siyuan-note/filelock v0.0.0-20221007163134-7e64809023ef
|
github.com/siyuan-note/filelock v0.0.0-20221007163134-7e64809023ef
|
||||||
|
|
|
||||||
|
|
@ -355,6 +355,8 @@ github.com/shurcooL/users v0.0.0-20180125191416-49c67e49c537/go.mod h1:QJTqeLYED
|
||||||
github.com/shurcooL/webdavfs v0.0.0-20170829043945-18c3829fa133/go.mod h1:hKmq5kWdCj2z2KEozexVbfEZIWiTjhE0+UjmZgPqehw=
|
github.com/shurcooL/webdavfs v0.0.0-20170829043945-18c3829fa133/go.mod h1:hKmq5kWdCj2z2KEozexVbfEZIWiTjhE0+UjmZgPqehw=
|
||||||
github.com/siyuan-note/dejavu v0.0.0-20221031154617-cd9466fb0785 h1:ZvlTJvaYf7AsME4cR+qMZVxvRff23KRlkqtiHc/W4wI=
|
github.com/siyuan-note/dejavu v0.0.0-20221031154617-cd9466fb0785 h1:ZvlTJvaYf7AsME4cR+qMZVxvRff23KRlkqtiHc/W4wI=
|
||||||
github.com/siyuan-note/dejavu v0.0.0-20221031154617-cd9466fb0785/go.mod h1:+U86jfsvpacZBThE3Ouf/ZQ4EsB4jGPJsMO2iuRv0LQ=
|
github.com/siyuan-note/dejavu v0.0.0-20221031154617-cd9466fb0785/go.mod h1:+U86jfsvpacZBThE3Ouf/ZQ4EsB4jGPJsMO2iuRv0LQ=
|
||||||
|
github.com/siyuan-note/dejavu v0.0.0-20221031160243-9bedc511961f h1:pN62Dby/Pt4gejJqNJJxWW72LXBKP1ZF2f1vYh7L5Wg=
|
||||||
|
github.com/siyuan-note/dejavu v0.0.0-20221031160243-9bedc511961f/go.mod h1:+U86jfsvpacZBThE3Ouf/ZQ4EsB4jGPJsMO2iuRv0LQ=
|
||||||
github.com/siyuan-note/encryption v0.0.0-20220713091850-5ecd92177b75 h1:Bi7/7f29LW+Fm0cHc0J1NO1cZqyJwljSWVmfOqVZgaE=
|
github.com/siyuan-note/encryption v0.0.0-20220713091850-5ecd92177b75 h1:Bi7/7f29LW+Fm0cHc0J1NO1cZqyJwljSWVmfOqVZgaE=
|
||||||
github.com/siyuan-note/encryption v0.0.0-20220713091850-5ecd92177b75/go.mod h1:H8fyqqAbp9XreANjeSbc72zEdFfKTXYN34tc1TjZwtw=
|
github.com/siyuan-note/encryption v0.0.0-20220713091850-5ecd92177b75/go.mod h1:H8fyqqAbp9XreANjeSbc72zEdFfKTXYN34tc1TjZwtw=
|
||||||
github.com/siyuan-note/eventbus v0.0.0-20220916025349-3ac6e75522da h1:/jNhl7LC+9BhkWvNxuJDdsNfA/2wvfuj9mqWx4CbV90=
|
github.com/siyuan-note/eventbus v0.0.0-20220916025349-3ac6e75522da h1:/jNhl7LC+9BhkWvNxuJDdsNfA/2wvfuj9mqWx4CbV90=
|
||||||
|
|
|
||||||
|
|
@ -34,8 +34,8 @@ import (
|
||||||
"github.com/88250/gulu"
|
"github.com/88250/gulu"
|
||||||
"github.com/dustin/go-humanize"
|
"github.com/dustin/go-humanize"
|
||||||
"github.com/siyuan-note/dejavu"
|
"github.com/siyuan-note/dejavu"
|
||||||
|
"github.com/siyuan-note/dejavu/cloud"
|
||||||
"github.com/siyuan-note/dejavu/entity"
|
"github.com/siyuan-note/dejavu/entity"
|
||||||
"github.com/siyuan-note/dejavu/transport"
|
|
||||||
"github.com/siyuan-note/encryption"
|
"github.com/siyuan-note/encryption"
|
||||||
"github.com/siyuan-note/eventbus"
|
"github.com/siyuan-note/eventbus"
|
||||||
"github.com/siyuan-note/httpclient"
|
"github.com/siyuan-note/httpclient"
|
||||||
|
|
@ -809,17 +809,17 @@ func resetRepository(repo *dejavu.Repo) (index *entity.Index, err error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func newRepository() (ret *dejavu.Repo, err error) {
|
func newRepository() (ret *dejavu.Repo, err error) {
|
||||||
transportConf, err := buildRepoTransportConf()
|
cloudConf, err := buildCloudConf()
|
||||||
if nil != err {
|
if nil != err {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: 数据同步支持接入第三方对象存储服务 https://github.com/siyuan-note/siyuan/issues/6426
|
// TODO: 数据同步支持接入第三方对象存储服务 https://github.com/siyuan-note/siyuan/issues/6426
|
||||||
siyuanTransport := &transport.SiYuan{Conf: transportConf}
|
cloudSiYuan := &cloud.SiYuan{Conf: cloudConf}
|
||||||
|
|
||||||
ignoreLines := getIgnoreLines()
|
ignoreLines := getIgnoreLines()
|
||||||
ignoreLines = append(ignoreLines, "/.siyuan/conf.json") // 忽略旧版同步配置
|
ignoreLines = append(ignoreLines, "/.siyuan/conf.json") // 忽略旧版同步配置
|
||||||
ret, err = dejavu.NewRepo(util.DataDir, util.RepoDir, util.HistoryDir, util.TempDir, Conf.Repo.Key, ignoreLines, siyuanTransport)
|
ret, err = dejavu.NewRepo(util.DataDir, util.RepoDir, util.HistoryDir, util.TempDir, Conf.Repo.Key, ignoreLines, cloudSiYuan)
|
||||||
if nil != err {
|
if nil != err {
|
||||||
logging.LogErrorf("init data repo failed: %s", err)
|
logging.LogErrorf("init data repo failed: %s", err)
|
||||||
}
|
}
|
||||||
|
|
@ -998,7 +998,7 @@ func subscribeEvents() {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func buildRepoTransportConf() (ret *transport.Conf, err error) {
|
func buildCloudConf() (ret *cloud.Conf, err error) {
|
||||||
if !IsValidCloudDirName(Conf.Sync.CloudName) {
|
if !IsValidCloudDirName(Conf.Sync.CloudName) {
|
||||||
logging.LogWarnf("invalid cloud repo name, rename it to [main]")
|
logging.LogWarnf("invalid cloud repo name, rename it to [main]")
|
||||||
Conf.Sync.CloudName = "main"
|
Conf.Sync.CloudName = "main"
|
||||||
|
|
@ -1011,7 +1011,7 @@ func buildRepoTransportConf() (ret *transport.Conf, err error) {
|
||||||
token = Conf.User.UserToken
|
token = Conf.User.UserToken
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = &transport.Conf{
|
ret = &cloud.Conf{
|
||||||
Dir: Conf.Sync.CloudName,
|
Dir: Conf.Sync.CloudName,
|
||||||
UserID: userId,
|
UserID: userId,
|
||||||
Token: token,
|
Token: token,
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ import (
|
||||||
|
|
||||||
"github.com/88250/gulu"
|
"github.com/88250/gulu"
|
||||||
"github.com/dustin/go-humanize"
|
"github.com/dustin/go-humanize"
|
||||||
"github.com/siyuan-note/dejavu/transport"
|
"github.com/siyuan-note/dejavu/cloud"
|
||||||
"github.com/siyuan-note/logging"
|
"github.com/siyuan-note/logging"
|
||||||
"github.com/siyuan-note/siyuan/kernel/sql"
|
"github.com/siyuan-note/siyuan/kernel/sql"
|
||||||
"github.com/siyuan-note/siyuan/kernel/treenode"
|
"github.com/siyuan-note/siyuan/kernel/treenode"
|
||||||
|
|
@ -378,7 +378,7 @@ func ListCloudSyncDir() (syncDirs []*Sync, hSize string, err error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func formatErrorMsg(err error) string {
|
func formatErrorMsg(err error) string {
|
||||||
if errors.Is(err, transport.ErrCloudAuthFailed) {
|
if errors.Is(err, cloud.ErrCloudAuthFailed) {
|
||||||
return Conf.Language(31) + " v" + util.Ver
|
return Conf.Language(31) + " v" + util.Ver
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue