mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-01-06 16:58:49 +01:00
🎨 细化云端同步锁提升稳定性 https://github.com/siyuan-note/siyuan/issues/5887
This commit is contained in:
parent
90f45a420e
commit
3468fb0976
5 changed files with 17 additions and 11 deletions
|
|
@ -17,6 +17,7 @@
|
|||
package util
|
||||
|
||||
import (
|
||||
"io"
|
||||
"os"
|
||||
"path"
|
||||
"path/filepath"
|
||||
|
|
@ -32,6 +33,17 @@ import (
|
|||
|
||||
var WritingFileLock = sync.Mutex{}
|
||||
|
||||
func WriteFileSaferByReader(writePath string, reader io.Reader) (err error) {
|
||||
WritingFileLock.Lock()
|
||||
defer WritingFileLock.Unlock()
|
||||
|
||||
if err = gulu.File.WriteFileSaferByReader(writePath, reader, 0644); nil != err {
|
||||
logging.LogErrorf("write file [%s] failed: %s", writePath, err)
|
||||
return
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func WriteFileSafer(writePath string, data []byte) (err error) {
|
||||
WritingFileLock.Lock()
|
||||
defer WritingFileLock.Unlock()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue