🐛 Notebook data may be corrupted during data synchronization https://github.com/siyuan-note/siyuan/issues/9594

This commit is contained in:
Daniel 2023-11-06 22:13:04 +08:00
parent a721bbe6f0
commit 70c56c8e25
No known key found for this signature in database
GPG key ID: 86211BA83DF03017
24 changed files with 88 additions and 96 deletions

View file

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