mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-21 17:10:12 +01:00
🐛 Notebook data may be corrupted during data synchronization https://github.com/siyuan-note/siyuan/issues/9594
This commit is contained in:
parent
a721bbe6f0
commit
70c56c8e25
24 changed files with 88 additions and 96 deletions
|
|
@ -204,28 +204,21 @@ func renameFile(c *gin.Context) {
|
|||
|
||||
filePath := arg["path"].(string)
|
||||
filePath = filepath.Join(util.WorkspaceDir, filePath)
|
||||
_, err := os.Stat(filePath)
|
||||
if os.IsNotExist(err) {
|
||||
if !filelock.IsExist(filePath) {
|
||||
ret.Code = 404
|
||||
ret.Msg = err.Error()
|
||||
return
|
||||
}
|
||||
if nil != err {
|
||||
logging.LogErrorf("stat [%s] failed: %s", filePath, err)
|
||||
ret.Code = 500
|
||||
ret.Msg = err.Error()
|
||||
ret.Msg = "the [path] file or directory does not exist"
|
||||
return
|
||||
}
|
||||
|
||||
newPath := arg["newPath"].(string)
|
||||
newPath = filepath.Join(util.WorkspaceDir, newPath)
|
||||
if gulu.File.IsExist(newPath) {
|
||||
if filelock.IsExist(newPath) {
|
||||
ret.Code = 409
|
||||
ret.Msg = "the [newPath] file or directory already exists"
|
||||
return
|
||||
}
|
||||
|
||||
if err = filelock.Rename(filePath, newPath); nil != err {
|
||||
if err := filelock.Rename(filePath, newPath); nil != err {
|
||||
logging.LogErrorf("rename file [%s] to [%s] failed: %s", filePath, newPath, err)
|
||||
ret.Code = 500
|
||||
ret.Msg = err.Error()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue