Merge remote-tracking branch 'origin/dev' into dev
This commit is contained in:
commit
e1b45b40e5
4 changed files with 45 additions and 29 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-20220626025117-e5db5c782cbb
|
||||
github.com/siyuan-note/dejavu v0.0.0-20220627141634-53a7e4ef9840
|
||||
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-20220616063212-74cfba0754ee
|
||||
|
|
|
@ -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-20220626025117-e5db5c782cbb h1:7HmFGziI6a8JctJ9ouuZ4fHSsFH1GXhGfoN5pxIc2Ds=
|
||||
github.com/siyuan-note/dejavu v0.0.0-20220626025117-e5db5c782cbb/go.mod h1:i7dnOgHM41EA7xIX2CYSxYe0WhksGZidQQsLvWryK7w=
|
||||
github.com/siyuan-note/dejavu v0.0.0-20220627141634-53a7e4ef9840 h1:H/Gb6d/Q9/7LK/T9KuuqIXlZGdj5rLFIVNFsJ00r00U=
|
||||
github.com/siyuan-note/dejavu v0.0.0-20220627141634-53a7e4ef9840/go.mod h1:0t+TpAdsrrv+6LkhDlJY2Gl92CQexgp8KWOBp5Ah9kU=
|
||||
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=
|
||||
|
|
|
@ -187,9 +187,8 @@ func GetRepoIndexLogs(page int) (logs []*dejavu.Log, pageCount, totalCount int,
|
|||
return
|
||||
}
|
||||
|
||||
repo, err := dejavu.NewRepo(util.DataDir, util.RepoDir, Conf.Repo.Key)
|
||||
repo, err := newRepository()
|
||||
if nil != err {
|
||||
util.LogErrorf("init data repository failed: %s", err)
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -299,9 +298,8 @@ func CheckoutRepo(id string) (err error) {
|
|||
return
|
||||
}
|
||||
|
||||
repo, err := dejavu.NewRepo(util.DataDir, util.RepoDir, Conf.Repo.Key)
|
||||
repo, err := newRepository()
|
||||
if nil != err {
|
||||
util.LogErrorf("init data repo failed: %s", err)
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -349,9 +347,8 @@ func IndexRepo(memo string) (err error) {
|
|||
return
|
||||
}
|
||||
|
||||
repo, err := dejavu.NewRepo(util.DataDir, util.RepoDir, Conf.Repo.Key)
|
||||
repo, err := newRepository()
|
||||
if nil != err {
|
||||
util.LogErrorf("init data repo failed: %s", err)
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -398,9 +395,8 @@ func indexRepoBeforeCloudSync() {
|
|||
return
|
||||
}
|
||||
|
||||
repo, err := dejavu.NewRepo(util.DataDir, util.RepoDir, Conf.Repo.Key)
|
||||
repo, err := newRepository()
|
||||
if nil != err {
|
||||
util.LogErrorf("init data repo failed: %s", err)
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -442,9 +438,8 @@ func syncRepo() (err error) {
|
|||
return
|
||||
}
|
||||
|
||||
repo, err := dejavu.NewRepo(util.DataDir, util.RepoDir, Conf.Repo.Key)
|
||||
repo, err := newRepository()
|
||||
if nil != err {
|
||||
util.LogErrorf("init data repo failed: %s", err)
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -457,3 +452,12 @@ func syncRepo() (err error) {
|
|||
util.PushStatusBar(fmt.Sprintf(Conf.Language(149), elapsed.Seconds()))
|
||||
return
|
||||
}
|
||||
|
||||
func newRepository() (ret *dejavu.Repo, err error) {
|
||||
ignoreLines := getIgnoreLines()
|
||||
ret, err = dejavu.NewRepo(util.DataDir, util.RepoDir, Conf.Repo.Key, ignoreLines)
|
||||
if nil != err {
|
||||
util.LogErrorf("init data repository failed: %s", err)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
|
|
@ -1262,10 +1262,31 @@ func getSyncExcludedList(localDirPath string) (ret map[string]bool) {
|
|||
}
|
||||
|
||||
func getSyncIgnoreList() (ret []string) {
|
||||
lines := getIgnoreLines()
|
||||
if 1 > len(lines) {
|
||||
return
|
||||
}
|
||||
|
||||
gi := gitignore.CompileIgnoreLines(lines...)
|
||||
filepath.Walk(util.DataDir, func(p string, info os.FileInfo, err error) error {
|
||||
p = strings.TrimPrefix(p, util.DataDir+string(os.PathSeparator))
|
||||
p = filepath.ToSlash(p)
|
||||
if gi.MatchesPath(p) {
|
||||
ret = append(ret, p)
|
||||
}
|
||||
return nil
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
func getIgnoreLines() (ret []string) {
|
||||
ignore := filepath.Join(util.DataDir, ".siyuan", "syncignore")
|
||||
os.MkdirAll(filepath.Dir(ignore), 0755)
|
||||
err := os.MkdirAll(filepath.Dir(ignore), 0755)
|
||||
if nil != err {
|
||||
return
|
||||
}
|
||||
if !gulu.File.IsExist(ignore) {
|
||||
if err := gulu.File.WriteFileSafer(ignore, nil, 0644); nil != err {
|
||||
if err = gulu.File.WriteFileSafer(ignore, nil, 0644); nil != err {
|
||||
util.LogErrorf("create syncignore [%s] failed: %s", ignore, err)
|
||||
return
|
||||
}
|
||||
|
@ -1277,23 +1298,14 @@ func getSyncIgnoreList() (ret []string) {
|
|||
}
|
||||
dataStr := string(data)
|
||||
dataStr = strings.ReplaceAll(dataStr, "\r\n", "\n")
|
||||
lines := strings.Split(dataStr, "\n")
|
||||
ret = strings.Split(dataStr, "\n")
|
||||
|
||||
// 默认忽略帮助文档
|
||||
lines = append(lines, "20210808180117-6v0mkxr/**/*")
|
||||
lines = append(lines, "20210808180117-czj9bvb/**/*")
|
||||
lines = append(lines, "20211226090932-5lcq56f/**/*")
|
||||
ret = append(ret, "20210808180117-6v0mkxr/**/*")
|
||||
ret = append(ret, "20210808180117-czj9bvb/**/*")
|
||||
ret = append(ret, "20211226090932-5lcq56f/**/*")
|
||||
|
||||
lines = gulu.Str.RemoveDuplicatedElem(lines)
|
||||
gi := gitignore.CompileIgnoreLines(lines...)
|
||||
filepath.Walk(util.DataDir, func(p string, info os.FileInfo, err error) error {
|
||||
p = strings.TrimPrefix(p, util.DataDir+string(os.PathSeparator))
|
||||
p = filepath.ToSlash(p)
|
||||
if gi.MatchesPath(p) {
|
||||
ret = append(ret, p)
|
||||
}
|
||||
return nil
|
||||
})
|
||||
ret = gulu.Str.RemoveDuplicatedElem(ret)
|
||||
return
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue