Merge remote-tracking branch 'origin/dev' into dev

This commit is contained in:
Vanessa 2025-03-28 13:46:07 +08:00
commit 8e84c83a4a
2 changed files with 32 additions and 4 deletions

View file

@ -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)
}

View file

@ -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)