mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-01-22 00:06:09 +01:00
Merge remote-tracking branch 'origin/dev' into dev
This commit is contained in:
commit
8e84c83a4a
2 changed files with 32 additions and 4 deletions
|
|
@ -279,3 +279,15 @@ func SetTimezone(container, appDir, timezoneID string) {
|
|||
func DisableFeature(feature string) {
|
||||
util.DisableFeature(feature)
|
||||
}
|
||||
|
||||
func FilepathBase(path string) string {
|
||||
return filepath.Base(path)
|
||||
}
|
||||
|
||||
func FilterUploadFileName(name string) string {
|
||||
return util.FilterUploadFileName(name)
|
||||
}
|
||||
|
||||
func AssetName(name string) string {
|
||||
return util.AssetName(name)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,9 +41,28 @@ func MoveLocalShorthands(boxID, hPath, parentID, id string) (retID string, err e
|
|||
|
||||
buff := bytes.Buffer{}
|
||||
var toRemoves []string
|
||||
assetsDir := filepath.Join(util.DataDir, "assets")
|
||||
for _, entry := range entries {
|
||||
if entry.IsDir() {
|
||||
continue
|
||||
if "assets" == entry.Name() {
|
||||
assetsEntries, readErr := os.ReadDir(filepath.Join(shorthandsDir, entry.Name()))
|
||||
if nil != readErr {
|
||||
logging.LogErrorf("read dir [%s] failed: %s", shorthandsDir, readErr)
|
||||
continue
|
||||
}
|
||||
for _, assetEntry := range assetsEntries {
|
||||
if assetEntry.IsDir() {
|
||||
continue
|
||||
}
|
||||
|
||||
p := filepath.Join(shorthandsDir, entry.Name(), assetEntry.Name())
|
||||
assetWritePath := filepath.Join(assetsDir, assetEntry.Name())
|
||||
if renameErr := os.Rename(p, assetWritePath); nil != renameErr {
|
||||
logging.LogErrorf("rename file [%s] to [%s] failed: %s", p, assetWritePath, renameErr)
|
||||
continue
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if filepath.Ext(entry.Name()) != ".md" {
|
||||
|
|
@ -59,7 +78,6 @@ func MoveLocalShorthands(boxID, hPath, parentID, id string) (retID string, err e
|
|||
|
||||
buff.Write(bytes.TrimSpace(data))
|
||||
buff.WriteString("\n\n")
|
||||
logging.LogInfof("read shorthand [%s] content [%s]", p, data)
|
||||
toRemoves = append(toRemoves, p)
|
||||
}
|
||||
|
||||
|
|
@ -77,8 +95,6 @@ func MoveLocalShorthands(boxID, hPath, parentID, id string) (retID string, err e
|
|||
return
|
||||
}
|
||||
|
||||
logging.LogInfof("shorthand content [%s]", content)
|
||||
|
||||
retID, err = CreateWithMarkdown("", boxID, hPath, content, parentID, id, false, "")
|
||||
if nil != err {
|
||||
logging.LogErrorf("create doc failed: %s", err)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue