Skip to content

Commit

Permalink
🎨 Improve cloud data synchronization stability siyuan-note/siyuan#12543
Browse files Browse the repository at this point in the history
  • Loading branch information
88250 committed Sep 22, 2024
1 parent a4c9760 commit e62caee
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ func (repo *Repo) PutIndex(index *entity.Index) (err error) {
return repo.store.PutIndex(index)
}

var workspaceDataDirs = []string{"assets", "emojis", "snippets", "storage", "templates", "widgets"}
var workspaceDataDirs = []string{"assets", "emojis", "snippets", "storage", "templates", "widgets", "plugins", "public", "snippets"}
var removeEmptyDirExcludes = append(workspaceDataDirs, ".git")

// Checkout 将仓库中的数据迁出到 repo 数据文件夹下。context 参数用于发布事件时传递调用上下文。
Expand Down Expand Up @@ -972,7 +972,7 @@ func (repo *Repo) openFile(file *entity.File) (ret []byte, err error) {
func (repo *Repo) checkoutFiles(files []*entity.File, context map[string]interface{}) (err error) {
//now := time.Now()

var dotSiYuans, assets, emojis, storage, widgets, templates, public, others, all []*entity.File
var dotSiYuans, assets, emojis, storage, plugins, widgets, templates, public, others, all []*entity.File
for _, file := range files {
if strings.Contains(file.Path, ".siyuan") {
dotSiYuans = append(dotSiYuans, file)
Expand All @@ -982,6 +982,8 @@ func (repo *Repo) checkoutFiles(files []*entity.File, context map[string]interfa
emojis = append(emojis, file)
} else if strings.HasPrefix(file.Path, "/storage/") {
storage = append(storage, file)
} else if strings.HasPrefix(file.Path, "/plugins/") {
plugins = append(plugins, file)
} else if strings.HasPrefix(file.Path, "/widgets/") {
widgets = append(widgets, file)
} else if strings.HasPrefix(file.Path, "/templates/") {
Expand Down Expand Up @@ -1012,6 +1014,10 @@ func (repo *Repo) checkoutFiles(files []*entity.File, context map[string]interfa
all = append(all, storage...)
storage = nil

sort.Slice(plugins, func(i, j int) bool { return strings.Count(plugins[i].Path, "/") < strings.Count(plugins[j].Path, "/") })
all = append(all, plugins...)
plugins = nil

sort.Slice(widgets, func(i, j int) bool { return strings.Count(widgets[i].Path, "/") < strings.Count(widgets[j].Path, "/") })
all = append(all, widgets...)
widgets = nil
Expand Down

0 comments on commit e62caee

Please sign in to comment.