🎨 Improve exporting data https://github.com/siyuan-note/siyuan/issues/13500
This commit is contained in:
parent
7395554ebe
commit
560af8e542
1 changed files with 21 additions and 12 deletions
|
@ -1707,6 +1707,11 @@ func exportSYZip(boxID, rootDirPath, baseFolderName string, docPaths []string) (
|
|||
}
|
||||
|
||||
// 导出引用的资源文件
|
||||
assetPathMap, err := allAssetAbsPaths()
|
||||
if nil != err {
|
||||
logging.LogWarnf("get assets abs path failed: %s", err)
|
||||
return
|
||||
}
|
||||
copiedAssets := hashset.New()
|
||||
for _, tree := range trees {
|
||||
var assets []string
|
||||
|
@ -1730,14 +1735,14 @@ func exportSYZip(boxID, rootDirPath, baseFolderName string, docPaths []string) (
|
|||
continue
|
||||
}
|
||||
|
||||
srcPath, assetErr := GetAssetAbsPath(asset)
|
||||
if nil != assetErr {
|
||||
logging.LogWarnf("get asset [%s] abs path failed: %s", asset, assetErr)
|
||||
srcPath := assetPathMap[asset]
|
||||
if "" == srcPath {
|
||||
logging.LogWarnf("get asset [%s] abs path failed", asset)
|
||||
continue
|
||||
}
|
||||
|
||||
destPath := filepath.Join(exportFolder, asset)
|
||||
assetErr = filelock.Copy(srcPath, destPath)
|
||||
assetErr := filelock.Copy(srcPath, destPath)
|
||||
if nil != assetErr {
|
||||
logging.LogErrorf("copy asset from [%s] to [%s] failed: %s", srcPath, destPath, assetErr)
|
||||
continue
|
||||
|
@ -1795,9 +1800,9 @@ func exportSYZip(boxID, rootDirPath, baseFolderName string, docPaths []string) (
|
|||
}
|
||||
|
||||
destPath := filepath.Join(exportFolder, asset.Content)
|
||||
srcPath, assetErr := GetAssetAbsPath(asset.Content)
|
||||
if nil != assetErr {
|
||||
logging.LogWarnf("get asset [%s] abs path failed: %s", asset.Content, assetErr)
|
||||
srcPath := assetPathMap[asset.Content]
|
||||
if "" == srcPath {
|
||||
logging.LogWarnf("get asset [%s] abs path failed", asset.Content)
|
||||
continue
|
||||
}
|
||||
|
||||
|
@ -3150,6 +3155,11 @@ func exportPandocConvertZip(baseFolderName string, docPaths []string,
|
|||
}
|
||||
|
||||
wrotePathHash := map[string]string{}
|
||||
assetsPathMap, err := allAssetAbsPaths()
|
||||
if nil != err {
|
||||
logging.LogWarnf("get assets abs path failed: %s", err)
|
||||
return
|
||||
}
|
||||
|
||||
luteEngine := util.NewLute()
|
||||
for i, p := range docPaths {
|
||||
|
@ -3187,15 +3197,14 @@ func exportPandocConvertZip(baseFolderName string, docPaths []string,
|
|||
continue
|
||||
}
|
||||
|
||||
srcPath, err := GetAssetAbsPath(asset)
|
||||
if err != nil {
|
||||
logging.LogWarnf("get asset [%s] abs path failed: %s", asset, err)
|
||||
srcPath := assetsPathMap[asset]
|
||||
if "" == srcPath {
|
||||
logging.LogWarnf("get asset [%s] abs path failed", asset)
|
||||
continue
|
||||
}
|
||||
|
||||
destPath := filepath.Join(writeFolder, asset)
|
||||
err = filelock.Copy(srcPath, destPath)
|
||||
if err != nil {
|
||||
if copyErr := filelock.Copy(srcPath, destPath); copyErr != nil {
|
||||
logging.LogErrorf("copy asset from [%s] to [%s] failed: %s", srcPath, destPath, err)
|
||||
continue
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue