mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-05-04 20:32:12 +08:00
🎨 Improve export av
This commit is contained in:
parent
8443f735ff
commit
058d652e71
@ -1479,10 +1479,9 @@ func exportSYZip(boxID, rootDirPath, baseFolderName string, docPaths []string) (
|
|||||||
return ast.WalkContinue
|
return ast.WalkContinue
|
||||||
}
|
}
|
||||||
|
|
||||||
// 导出资源文件列 https://github.com/siyuan-note/siyuan/issues/9919
|
|
||||||
for _, keyValues := range attrView.KeyValues {
|
for _, keyValues := range attrView.KeyValues {
|
||||||
switch keyValues.Key.Type {
|
switch keyValues.Key.Type {
|
||||||
case av.KeyTypeMAsset:
|
case av.KeyTypeMAsset: // 导出资源文件列 https://github.com/siyuan-note/siyuan/issues/9919
|
||||||
for _, value := range keyValues.Values {
|
for _, value := range keyValues.Values {
|
||||||
for _, asset := range value.MAsset {
|
for _, asset := range value.MAsset {
|
||||||
if !isRelativePath([]byte(asset.Content)) {
|
if !isRelativePath([]byte(asset.Content)) {
|
||||||
@ -1501,22 +1500,11 @@ func exportSYZip(boxID, rootDirPath, baseFolderName string, docPaths []string) (
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case av.KeyTypeRelation:
|
|
||||||
if nil == keyValues.Key.Relation {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
|
|
||||||
relAvJSONPath := av.GetAttributeViewDataPath(keyValues.Key.Relation.AvID)
|
|
||||||
if !filelock.IsExist(relAvJSONPath) {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
|
|
||||||
if copyErr := filelock.Copy(relAvJSONPath, filepath.Join(exportStorageAvDir, avID+".json")); nil != copyErr {
|
|
||||||
logging.LogErrorf("copy av json failed: %s", copyErr)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 级联导出关联列关联的数据库
|
||||||
|
exportRelationAvs(avID, exportStorageAvDir)
|
||||||
return ast.WalkContinue
|
return ast.WalkContinue
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -1605,6 +1593,47 @@ func exportSYZip(boxID, rootDirPath, baseFolderName string, docPaths []string) (
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func exportRelationAvs(avID, exportStorageAvDir string) {
|
||||||
|
avIDs := hashset.New()
|
||||||
|
avIDs.Add(avID)
|
||||||
|
walkRelationAvs(avID, exportStorageAvDir, avIDs)
|
||||||
|
|
||||||
|
for _, v := range avIDs.Values() {
|
||||||
|
relAvID := v.(string)
|
||||||
|
relAvJSONPath := av.GetAttributeViewDataPath(relAvID)
|
||||||
|
if !filelock.IsExist(relAvJSONPath) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
if copyErr := filelock.Copy(relAvJSONPath, filepath.Join(exportStorageAvDir, relAvID+".json")); nil != copyErr {
|
||||||
|
logging.LogErrorf("copy av json failed: %s", copyErr)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func walkRelationAvs(avID, exportStorageAvDir string, exportAvIDs *hashset.Set) {
|
||||||
|
if exportAvIDs.Contains(avID) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
attrView, _ := av.ParseAttributeView(avID)
|
||||||
|
if nil == attrView {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
exportAvIDs.Add(avID)
|
||||||
|
for _, keyValues := range attrView.KeyValues {
|
||||||
|
switch keyValues.Key.Type {
|
||||||
|
case av.KeyTypeRelation: // 导出关联列
|
||||||
|
if nil == keyValues.Key.Relation {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
walkRelationAvs(keyValues.Key.Relation.AvID, exportStorageAvDir, exportAvIDs)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func ExportMarkdownContent(id string) (hPath, exportedMd string) {
|
func ExportMarkdownContent(id string) (hPath, exportedMd string) {
|
||||||
return exportMarkdownContent(id)
|
return exportMarkdownContent(id)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user