mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-01-06 08:48:49 +01:00
🎨 开源云端同步服务实现 https://github.com/siyuan-note/siyuan/issues/6445
This commit is contained in:
parent
be6380cbf7
commit
46cec73e2a
4 changed files with 7 additions and 28 deletions
|
|
@ -36,7 +36,7 @@ require (
|
|||
github.com/panjf2000/ants/v2 v2.6.0
|
||||
github.com/patrickmn/go-cache v2.1.0+incompatible
|
||||
github.com/radovskyb/watcher v1.0.7
|
||||
github.com/siyuan-note/dejavu v0.0.0-20221102102630-25556844ddab
|
||||
github.com/siyuan-note/dejavu v0.0.0-20221102120909-ed9ad2509c64
|
||||
github.com/siyuan-note/encryption v0.0.0-20220713091850-5ecd92177b75
|
||||
github.com/siyuan-note/eventbus v0.0.0-20220916025349-3ac6e75522da
|
||||
github.com/siyuan-note/filelock v0.0.0-20221007163134-7e64809023ef
|
||||
|
|
|
|||
|
|
@ -353,10 +353,8 @@ github.com/shurcooL/reactions v0.0.0-20181006231557-f2e0b4ca5b82/go.mod h1:TCR1l
|
|||
github.com/shurcooL/sanitized_anchor_name v0.0.0-20170918181015-86672fcb3f95/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
|
||||
github.com/shurcooL/users v0.0.0-20180125191416-49c67e49c537/go.mod h1:QJTqeLYEDaXHZDBsXlPCDqdhQuJkuw4NOtaxYe3xii4=
|
||||
github.com/shurcooL/webdavfs v0.0.0-20170829043945-18c3829fa133/go.mod h1:hKmq5kWdCj2z2KEozexVbfEZIWiTjhE0+UjmZgPqehw=
|
||||
github.com/siyuan-note/dejavu v0.0.0-20221102101918-9258bfd2c7ca h1:yxlwyy/GxuzIBhTadAxjXNGAJYc3yrTjX8Yqq1SlVg4=
|
||||
github.com/siyuan-note/dejavu v0.0.0-20221102101918-9258bfd2c7ca/go.mod h1:+U86jfsvpacZBThE3Ouf/ZQ4EsB4jGPJsMO2iuRv0LQ=
|
||||
github.com/siyuan-note/dejavu v0.0.0-20221102102630-25556844ddab h1:pQJRm7GFp7DS3kCqlGVLq5T1jnIVNwOytbkr1BjByvY=
|
||||
github.com/siyuan-note/dejavu v0.0.0-20221102102630-25556844ddab/go.mod h1:+U86jfsvpacZBThE3Ouf/ZQ4EsB4jGPJsMO2iuRv0LQ=
|
||||
github.com/siyuan-note/dejavu v0.0.0-20221102120909-ed9ad2509c64 h1:psY8hXz/t7cwqJFR+6+vebb5s3P1AzqfkaJ+gIQGLjw=
|
||||
github.com/siyuan-note/dejavu v0.0.0-20221102120909-ed9ad2509c64/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/go.mod h1:H8fyqqAbp9XreANjeSbc72zEdFfKTXYN34tc1TjZwtw=
|
||||
github.com/siyuan-note/eventbus v0.0.0-20220916025349-3ac6e75522da h1:/jNhl7LC+9BhkWvNxuJDdsNfA/2wvfuj9mqWx4CbV90=
|
||||
|
|
|
|||
|
|
@ -1009,7 +1009,7 @@ func subscribeEvents() {
|
|||
}
|
||||
|
||||
func buildCloudConf() (ret *cloud.Conf, err error) {
|
||||
if !IsValidCloudDirName(Conf.Sync.CloudName) {
|
||||
if !cloud.IsValidCloudDirName(Conf.Sync.CloudName) {
|
||||
logging.LogWarnf("invalid cloud repo name, rename it to [main]")
|
||||
Conf.Sync.CloudName = "main"
|
||||
Conf.Save()
|
||||
|
|
|
|||
|
|
@ -25,7 +25,6 @@ import (
|
|||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
"unicode/utf8"
|
||||
|
||||
"github.com/88250/gulu"
|
||||
"github.com/dustin/go-humanize"
|
||||
|
|
@ -70,7 +69,7 @@ func BootSyncData() {
|
|||
util.IncBootProgress(3, "Syncing data from the cloud...")
|
||||
BootSyncSucc = 0
|
||||
|
||||
if !IsSubscriber() || !Conf.Sync.Enabled || "" == Conf.Sync.CloudName || !IsValidCloudDirName(Conf.Sync.CloudName) {
|
||||
if !IsSubscriber() || !Conf.Sync.Enabled || "" == Conf.Sync.CloudName || !cloud.IsValidCloudDirName(Conf.Sync.CloudName) {
|
||||
return
|
||||
}
|
||||
|
||||
|
|
@ -135,7 +134,7 @@ func SyncData(boot, exit, byHand bool) {
|
|||
return
|
||||
}
|
||||
|
||||
if !IsValidCloudDirName(Conf.Sync.CloudName) {
|
||||
if !cloud.IsValidCloudDirName(Conf.Sync.CloudName) {
|
||||
return
|
||||
}
|
||||
|
||||
|
|
@ -297,7 +296,7 @@ func CreateCloudSyncDir(name string) (err error) {
|
|||
|
||||
name = strings.TrimSpace(name)
|
||||
name = gulu.Str.RemoveInvisible(name)
|
||||
if !IsValidCloudDirName(name) {
|
||||
if !cloud.IsValidCloudDirName(name) {
|
||||
return errors.New(Conf.Language(37))
|
||||
}
|
||||
|
||||
|
|
@ -405,24 +404,6 @@ func formatErrorMsg(err error) string {
|
|||
return msg
|
||||
}
|
||||
|
||||
func IsValidCloudDirName(cloudDirName string) bool {
|
||||
if 16 < utf8.RuneCountInString(cloudDirName) || 1 > utf8.RuneCountInString(cloudDirName) {
|
||||
return false
|
||||
}
|
||||
|
||||
chars := []byte{'~', '`', '!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '+', '=',
|
||||
'[', ']', '{', '}', '\\', '|', ';', ':', '\'', '"', '<', ',', '>', '.', '?', '/', ' '}
|
||||
var charsStr string
|
||||
for _, char := range chars {
|
||||
charsStr += string(char)
|
||||
}
|
||||
|
||||
if strings.ContainsAny(cloudDirName, charsStr) {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func getIgnoreLines() (ret []string) {
|
||||
ignore := filepath.Join(util.DataDir, ".siyuan", "syncignore")
|
||||
err := os.MkdirAll(filepath.Dir(ignore), 0755)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue