🎨 细化云端同步锁提升稳定性 https://github.com/siyuan-note/siyuan/issues/5887

This commit is contained in:
Liang Ding 2022-09-17 22:23:44 +08:00
parent 7bc8fba466
commit 90f45a420e
No known key found for this signature in database
GPG key ID: 136F30F901A2231D
15 changed files with 79 additions and 81 deletions

View file

@ -291,6 +291,9 @@ func (box *Box) Move(oldPath, newPath string) error {
fromPath := filepath.Join(boxLocalPath, oldPath)
toPath := filepath.Join(boxLocalPath, newPath)
filelock.ReleaseFileLocks(fromPath)
util.WritingFileLock.Lock()
defer util.WritingFileLock.Unlock()
if err := os.Rename(fromPath, toPath); nil != err {
msg := fmt.Sprintf(Conf.Language(5), box.Name, fromPath, err)
logging.LogErrorf("move [path=%s] in box [%s] failed: %s", fromPath, box.Name, err)
@ -310,8 +313,7 @@ func (box *Box) Move(oldPath, newPath string) error {
func (box *Box) Remove(path string) error {
boxLocalPath := filepath.Join(util.DataDir, box.ID)
filePath := filepath.Join(boxLocalPath, path)
filelock.ReleaseFileLocks(filePath)
if err := os.RemoveAll(filePath); nil != err {
if err := util.RemoveAll(filePath); nil != err {
msg := fmt.Sprintf(Conf.Language(7), box.Name, path, err)
logging.LogErrorf("remove [path=%s] in box [%s] failed: %s", path, box.ID, err)
return errors.New(msg)