From 727523883ee6573925770d8e704539e2339f8ebe Mon Sep 17 00:00:00 2001 From: Daniel <845765@qq.com> Date: Wed, 18 Jun 2025 12:12:20 +0800 Subject: [PATCH 1/3] :art: Database gallery view https://github.com/siyuan-note/siyuan/issues/10414 --- kernel/model/attribute_view.go | 1 + 1 file changed, 1 insertion(+) diff --git a/kernel/model/attribute_view.go b/kernel/model/attribute_view.go index 7a68a8211..0595d02c8 100644 --- a/kernel/model/attribute_view.go +++ b/kernel/model/attribute_view.go @@ -3068,6 +3068,7 @@ func sortAttributeViewRow(operation *Operation) (err error) { break } } + view.Gallery.CardIDs = util.InsertElem(view.Gallery.CardIDs, previousIndex, rowID) } err = av.SaveAttributeView(attrView) From abb69e136ba7cf2785a105256b954b9bf887a638 Mon Sep 17 00:00:00 2001 From: Daniel <845765@qq.com> Date: Wed, 18 Jun 2025 12:25:40 +0800 Subject: [PATCH 2/3] :art: Database gallery view https://github.com/siyuan-note/siyuan/issues/10414 --- kernel/model/attribute_view.go | 44 +++++++++++++++++++++------------- 1 file changed, 28 insertions(+), 16 deletions(-) diff --git a/kernel/model/attribute_view.go b/kernel/model/attribute_view.go index 0595d02c8..c3f32d44b 100644 --- a/kernel/model/attribute_view.go +++ b/kernel/model/attribute_view.go @@ -3035,23 +3035,23 @@ func sortAttributeViewRow(operation *Operation) (err error) { return } - var rowID string + var itemID string var idx, previousIndex int - for i, r := range view.Table.RowIDs { - if r == operation.ID { - rowID = r - idx = i - break - } - } - if "" == rowID { - rowID = operation.ID - view.Table.RowIDs = append(view.Table.RowIDs, rowID) - idx = len(view.Table.RowIDs) - 1 - } - switch view.LayoutType { case av.LayoutTypeTable: + for i, r := range view.Table.RowIDs { + if r == operation.ID { + itemID = r + idx = i + break + } + } + if "" == itemID { + itemID = operation.ID + view.Table.RowIDs = append(view.Table.RowIDs, itemID) + idx = len(view.Table.RowIDs) - 1 + } + view.Table.RowIDs = append(view.Table.RowIDs[:idx], view.Table.RowIDs[idx+1:]...) for i, r := range view.Table.RowIDs { if r == operation.PreviousID { @@ -3059,8 +3059,20 @@ func sortAttributeViewRow(operation *Operation) (err error) { break } } - view.Table.RowIDs = util.InsertElem(view.Table.RowIDs, previousIndex, rowID) + view.Table.RowIDs = util.InsertElem(view.Table.RowIDs, previousIndex, itemID) case av.LayoutTypeGallery: + for i, c := range view.Gallery.CardIDs { + if c == operation.ID { + itemID = c + idx = i + break + } + } + if "" == itemID { + itemID = operation.ID + view.Gallery.CardIDs = append(view.Gallery.CardIDs, itemID) + idx = len(view.Gallery.CardIDs) - 1 + } view.Gallery.CardIDs = append(view.Gallery.CardIDs[:idx], view.Gallery.CardIDs[idx+1:]...) for i, c := range view.Gallery.CardIDs { if c == operation.PreviousID { @@ -3068,7 +3080,7 @@ func sortAttributeViewRow(operation *Operation) (err error) { break } } - view.Gallery.CardIDs = util.InsertElem(view.Gallery.CardIDs, previousIndex, rowID) + view.Gallery.CardIDs = util.InsertElem(view.Gallery.CardIDs, previousIndex, itemID) } err = av.SaveAttributeView(attrView) From 4092547251c681f5d398397aa4f4c466482a17c9 Mon Sep 17 00:00:00 2001 From: Jeffrey Chen <78434827+TCOTC@users.noreply.github.com> Date: Wed, 18 Jun 2025 16:46:58 +0800 Subject: [PATCH 3/3] :bug: Fix null pointers in file traversal (#15079) --- kernel/model/import.go | 56 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 54 insertions(+), 2 deletions(-) diff --git a/kernel/model/import.go b/kernel/model/import.go index 8bc6b4dae..9f02988d9 100644 --- a/kernel/model/import.go +++ b/kernel/model/import.go @@ -126,7 +126,9 @@ func ImportSY(zipPath, boxID, toPath string) (err error) { if err != nil { return err } - + if d == nil { + return nil + } if !d.IsDir() && strings.HasSuffix(d.Name(), ".sy") { syPaths = append(syPaths, path) } @@ -231,6 +233,12 @@ func ImportSY(zipPath, boxID, toPath string) (err error) { if gulu.File.IsExist(storageAvDir) { // 重新生成数据库数据 filelock.Walk(storageAvDir, func(path string, d fs.DirEntry, err error) error { + if err != nil { + return err + } + if d == nil { + return nil + } if !strings.HasSuffix(path, ".json") || !ast.IsNodeIDPattern(strings.TrimSuffix(d.Name(), ".json")) { return nil } @@ -468,7 +476,9 @@ func ImportSY(zipPath, boxID, toPath string) (err error) { if err != nil { return err } - + if d == nil { + return nil + } if d.IsDir() && ast.IsNodeIDPattern(d.Name()) { renamePaths[path] = path } @@ -540,6 +550,12 @@ func ImportSY(zipPath, boxID, toPath string) (err error) { // 将包含的资源文件统一移动到 data/assets/ 下 var assetsDirs []string filelock.Walk(unzipRootPath, func(path string, d fs.DirEntry, err error) error { + if err != nil { + return err + } + if d == nil { + return nil + } if strings.Contains(path, "assets") && d.IsDir() { assetsDirs = append(assetsDirs, path) } @@ -559,6 +575,12 @@ func ImportSY(zipPath, boxID, toPath string) (err error) { // 将包含的自定义表情统一移动到 data/emojis/ 下 unzipRootEmojisPath := filepath.Join(unzipRootPath, "emojis") filelock.Walk(unzipRootEmojisPath, func(path string, d fs.DirEntry, err error) error { + if err != nil { + return err + } + if d == nil { + return nil + } if !util.IsValidUploadFileName(d.Name()) { emojiFullName := filepath.Join(unzipRootEmojisPath, d.Name()) fullPathFilteredName := filepath.Join(unzipRootEmojisPath, util.FilterUploadFileName(d.Name())) @@ -572,6 +594,12 @@ func ImportSY(zipPath, boxID, toPath string) (err error) { }) var emojiDirs []string filelock.Walk(unzipRootPath, func(path string, d fs.DirEntry, err error) error { + if err != nil { + return err + } + if d == nil { + return nil + } if strings.Contains(path, "emojis") && d.IsDir() { emojiDirs = append(emojiDirs, path) } @@ -607,6 +635,12 @@ func ImportSY(zipPath, boxID, toPath string) (err error) { var treePaths []string filelock.Walk(unzipRootPath, func(path string, d fs.DirEntry, err error) error { + if err != nil { + return err + } + if d == nil { + return nil + } if d.IsDir() { if strings.HasPrefix(d.Name(), ".") { return filepath.SkipDir @@ -690,6 +724,12 @@ func ImportData(zipPath string) (err error) { tmpDataPath := filepath.Join(unzipPath, dirs[0].Name()) tmpDataEmojisPath := filepath.Join(tmpDataPath, "emojis") filelock.Walk(tmpDataEmojisPath, func(path string, d fs.DirEntry, err error) error { + if err != nil { + return err + } + if d == nil { + return nil + } if !util.IsValidUploadFileName(d.Name()) { emojiFullName := filepath.Join(tmpDataEmojisPath, d.Name()) fullPathFilteredName := filepath.Join(tmpDataEmojisPath, util.FilterUploadFileName(d.Name())) @@ -754,6 +794,12 @@ func ImportFromLocalPath(boxID, localPath string, toPath string) (err error) { // 收集所有资源文件 assets := map[string]string{} filelock.Walk(localPath, func(currentPath string, d fs.DirEntry, err error) error { + if err != nil { + return err + } + if d == nil { + return nil + } if localPath == currentPath { return nil } @@ -775,6 +821,12 @@ func ImportFromLocalPath(boxID, localPath string, toPath string) (err error) { count := 0 // md 转换 sy filelock.Walk(localPath, func(currentPath string, d fs.DirEntry, err error) error { + if err != nil { + return err + } + if d == nil { + return nil + } if strings.HasPrefix(d.Name(), ".") { if d.IsDir() { return filepath.SkipDir