An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:art: Include related assets when exporting the database to CSV https://github.com/siyuan-note/siyuan/issues/16645
Danielf9aa99bff843
diff --git a/kernel/model/export.go b/kernel/model/export.goindex 1c8781d327..2b28e60644 100644--- a/kernel/model/export.go+++ b/kernel/model/export.go@@ -164,6 +164,7 @@ func ExportAv2CSV(avID, blockID string) (zipPath string, err error) {return}+ var assets []stringrowNum := 1for _, row := range table.Rows {var rowVal []string@@ -204,12 +205,18 @@ func ExportAv2CSV(avID, blockID string) (zipPath string, err error) {buf.WriteString("](")buf.WriteString(a.Content)buf.WriteString(") ")+ if util.IsAssetLinkDest([]byte(a.Content), true) {+ assets = append(assets, a.Content)+ }} else if av.AssetTypeFile == a.Type {buf.WriteString("[")buf.WriteString(a.Name)buf.WriteString("](")buf.WriteString(a.Content)buf.WriteString(") ")+ if util.IsAssetLinkDest([]byte(a.Content), true) {+ assets = append(assets, a.Content)+ }} else {buf.WriteString(a.Content)buf.WriteString(" ")@@ -219,6 +226,37 @@ func ExportAv2CSV(avID, blockID string) (zipPath string, err error) {}} else if av.KeyTypeLineNumber == cell.Value.Type {val = strconv.Itoa(rowNum)+ } else if av.KeyTypeRollup == cell.Value.Type {+ for _, content := range cell.Value.Rollup.Contents {+ if av.KeyTypeMAsset == content.Type {+ buf := &bytes.Buffer{}+ for _, a := range content.MAsset {+ if av.AssetTypeImage == a.Type {+ buf.WriteString("+ buf.WriteString(a.Content)+ buf.WriteString(") ")+ if util.IsAssetLinkDest([]byte(a.Content), true) {+ assets = append(assets, a.Content)+ }+ } else if av.AssetTypeFile == a.Type {+ buf.WriteString("[")+ buf.WriteString(a.Name)+ buf.WriteString("](")+ buf.WriteString(a.Content)+ buf.WriteString(") ")+ if util.IsAssetLinkDest([]byte(a.Content), true) {+ assets = append(assets, a.Content)+ }+ } else {+ buf.WriteString(a.Content)+ buf.WriteString(" ")+ }+ }+ val = strings.TrimSpace(buf.String())+ }+ }}if "" == val {@@ -237,6 +275,18 @@ func ExportAv2CSV(avID, blockID string) (zipPath string, err error) {}writer.Flush()+ for _, asset := range assets {+ srcAbsPath, getErr := GetAssetAbsPath(asset)+ if getErr != nil {+ logging.LogWarnf("resolve path of asset [%s] failed: %s", asset, getErr)+ continue+ }+ targetAbsPath := filepath.Join(exportFolder, asset)+ if copyErr := filelock.Copy(srcAbsPath, targetAbsPath); copyErr != nil {+ logging.LogWarnf("copy asset from [%s] to [%s] failed: %s", srcAbsPath, targetAbsPath, copyErr)+ }+ }+zipPath = exportFolder + ".db.zip"zip, err := gulu.Zip.Create(zipPath)if err != nil {