mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-16 22:50:13 +01:00
🐛 复制资源文件后导出再导入后丢失 Fix https://github.com/siyuan-note/siyuan/issues/5320
This commit is contained in:
parent
ea4f722edb
commit
a0a3d2f28e
3 changed files with 34 additions and 25 deletions
|
|
@ -24,6 +24,7 @@ import (
|
|||
"strings"
|
||||
|
||||
"github.com/88250/gulu"
|
||||
"github.com/88250/lute/ast"
|
||||
)
|
||||
|
||||
func IsEmptyDir(p string) bool {
|
||||
|
|
@ -47,6 +48,23 @@ func RemoveID(name string) string {
|
|||
return name + ext
|
||||
}
|
||||
|
||||
func AssetName(name string) string {
|
||||
_, id := LastID(name)
|
||||
ext := path.Ext(name)
|
||||
name = name[0 : len(name)-len(ext)]
|
||||
if !IsIDPattern(id) {
|
||||
id = ast.NewNodeID()
|
||||
name = name + "-" + id + ext
|
||||
} else {
|
||||
if !IsIDPattern(name) {
|
||||
name = name[:len(name)-len(id)-1] + "-" + id + ext
|
||||
} else {
|
||||
name = name + ext
|
||||
}
|
||||
}
|
||||
return name
|
||||
}
|
||||
|
||||
func LastID(p string) (name, id string) {
|
||||
name = path.Base(p)
|
||||
ext := path.Ext(name)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue