mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-22 09:30:14 +01:00
:file: 移除文件锁 https://github.com/siyuan-note/siyuan/issues/6010
This commit is contained in:
parent
56129699b9
commit
69a9713776
38 changed files with 193 additions and 438 deletions
|
|
@ -39,7 +39,6 @@ import (
|
|||
"github.com/siyuan-note/httpclient"
|
||||
"github.com/siyuan-note/logging"
|
||||
"github.com/siyuan-note/siyuan/kernel/cache"
|
||||
"github.com/siyuan-note/siyuan/kernel/filesys"
|
||||
"github.com/siyuan-note/siyuan/kernel/search"
|
||||
"github.com/siyuan-note/siyuan/kernel/sql"
|
||||
"github.com/siyuan-note/siyuan/kernel/treenode"
|
||||
|
|
@ -142,7 +141,7 @@ func NetImg2LocalAssets(rootID string) (err error) {
|
|||
name = util.FilterFileName(name)
|
||||
name = "net-img-" + name + "-" + ast.NewNodeID() + ext
|
||||
writePath := filepath.Join(util.DataDir, "assets", name)
|
||||
if err = filesys.WriteFileSafer(writePath, data); nil != err {
|
||||
if err = filelock.WriteFile(writePath, data); nil != err {
|
||||
logging.LogErrorf("write downloaded net img [%s] to local assets [%s] failed: %s", u, writePath, err)
|
||||
return ast.WalkSkipChildren
|
||||
}
|
||||
|
|
@ -384,7 +383,7 @@ func saveWorkspaceAssets(assets []string) {
|
|||
logging.LogErrorf("create assets conf failed: %s", err)
|
||||
return
|
||||
}
|
||||
if err = filesys.WriteFileSafer(confPath, data); nil != err {
|
||||
if err = filelock.WriteFile(confPath, data); nil != err {
|
||||
logging.LogErrorf("write assets conf failed: %s", err)
|
||||
return
|
||||
}
|
||||
|
|
@ -479,7 +478,7 @@ func RenameAsset(oldPath, newName string) (err error) {
|
|||
|
||||
newName = util.AssetName(newName) + filepath.Ext(oldPath)
|
||||
newPath := "assets/" + newName
|
||||
if err = filesys.Copy(filepath.Join(util.DataDir, oldPath), filepath.Join(util.DataDir, newPath)); nil != err {
|
||||
if err = filelock.Copy(filepath.Join(util.DataDir, oldPath), filepath.Join(util.DataDir, newPath)); nil != err {
|
||||
logging.LogErrorf("copy asset [%s] failed: %s", oldPath, err)
|
||||
return
|
||||
}
|
||||
|
|
@ -493,7 +492,7 @@ func RenameAsset(oldPath, newName string) (err error) {
|
|||
pages := pagedPaths(filepath.Join(util.DataDir, notebook.ID), 32)
|
||||
for _, paths := range pages {
|
||||
for _, treeAbsPath := range paths {
|
||||
data, readErr := filelock.NoLockFileRead(treeAbsPath)
|
||||
data, readErr := filelock.ReadFile(treeAbsPath)
|
||||
if nil != readErr {
|
||||
logging.LogErrorf("get data [path=%s] failed: %s", treeAbsPath, readErr)
|
||||
err = readErr
|
||||
|
|
@ -505,7 +504,7 @@ func RenameAsset(oldPath, newName string) (err error) {
|
|||
}
|
||||
|
||||
data = bytes.Replace(data, []byte(oldName), []byte(newName), -1)
|
||||
if writeErr := filelock.NoLockFileWrite(treeAbsPath, data); nil != writeErr {
|
||||
if writeErr := filelock.WriteFile(treeAbsPath, data); nil != writeErr {
|
||||
logging.LogErrorf("write data [path=%s] failed: %s", treeAbsPath, writeErr)
|
||||
err = writeErr
|
||||
return
|
||||
|
|
@ -835,8 +834,6 @@ func copyDocAssetsToDataAssets(boxID, parentDocPath string) {
|
|||
}
|
||||
|
||||
func copyAssetsToDataAssets(rootPath string) {
|
||||
filelock.ReleaseFileLocks(rootPath)
|
||||
|
||||
var assetsDirPaths []string
|
||||
filepath.Walk(rootPath, func(path string, info fs.FileInfo, err error) error {
|
||||
if rootPath == path || nil == info {
|
||||
|
|
@ -861,7 +858,7 @@ func copyAssetsToDataAssets(rootPath string) {
|
|||
|
||||
dataAssetsPath := filepath.Join(util.DataDir, "assets")
|
||||
for _, assetsDirPath := range assetsDirPaths {
|
||||
if err := gulu.File.Copy(assetsDirPath, dataAssetsPath); nil != err {
|
||||
if err := filelock.Copy(assetsDirPath, dataAssetsPath); nil != err {
|
||||
logging.LogErrorf("copy tree assets from [%s] to [%s] failed: %s", assetsDirPaths, dataAssetsPath, err)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue