🎨 If a file with the same name exists during export PDF/Docx, it will be automatically renamed https://github.com/siyuan-note/siyuan/issues/11357

This commit is contained in:
Daniel 2024-05-12 17:37:32 +08:00
parent abf92b602c
commit 749ed8a4ac
No known key found for this signature in database
GPG key ID: 86211BA83DF03017
4 changed files with 36 additions and 19 deletions

View file

@ -36,6 +36,21 @@ import (
"github.com/siyuan-note/siyuan/kernel/util"
)
func getUniqueFilename(c *gin.Context) {
ret := gulu.Ret.NewResult()
defer c.JSON(http.StatusOK, ret)
arg, ok := util.JsonArg(c, ret)
if !ok {
return
}
filePath := arg["path"].(string)
ret.Data = map[string]interface{}{
"path": util.GetUniqueFilename(filePath),
}
}
func globalCopyFiles(c *gin.Context) {
ret := gulu.Ret.NewResult()
defer c.JSON(http.StatusOK, ret)

View file

@ -208,6 +208,7 @@ func ServeAPI(ginServer *gin.Engine) {
ginServer.Handle("POST", "/api/file/removeFile", model.CheckAuth, model.CheckReadonly, removeFile)
ginServer.Handle("POST", "/api/file/renameFile", model.CheckAuth, model.CheckReadonly, renameFile)
ginServer.Handle("POST", "/api/file/readDir", model.CheckAuth, readDir)
ginServer.Handle("POST", "/api/file/getUniqueFilename", model.CheckAuth, getUniqueFilename)
ginServer.Handle("POST", "/api/ref/refreshBacklink", model.CheckAuth, refreshBacklink)
ginServer.Handle("POST", "/api/ref/getBacklink", model.CheckAuth, getBacklink)