Merge remote-tracking branch 'origin/dev' into dev

This commit is contained in:
Vanessa 2024-02-06 21:30:55 +08:00
commit e11fe65932
7 changed files with 13 additions and 19 deletions

View file

@ -27,6 +27,7 @@ import (
"github.com/dustin/go-humanize"
ants "github.com/panjf2000/ants/v2"
"github.com/siyuan-note/filelock"
"github.com/siyuan-note/httpclient"
"github.com/siyuan-note/logging"
"github.com/siyuan-note/siyuan/kernel/util"
@ -214,7 +215,7 @@ func InstallPlugin(repoURL, repoHash, installPath string, systemID string) error
}
func UninstallPlugin(installPath string) error {
if err := os.RemoveAll(installPath); nil != err {
if err := filelock.Remove(installPath); nil != err {
logging.LogErrorf("remove plugin [%s] failed: %s", installPath, err)
return errors.New("remove community plugin failed")
}

View file

@ -27,6 +27,7 @@ import (
"github.com/dustin/go-humanize"
"github.com/panjf2000/ants/v2"
"github.com/siyuan-note/filelock"
"github.com/siyuan-note/httpclient"
"github.com/siyuan-note/logging"
"github.com/siyuan-note/siyuan/kernel/util"
@ -176,7 +177,7 @@ func InstallTemplate(repoURL, repoHash, installPath string, systemID string) err
}
func UninstallTemplate(installPath string) error {
if err := os.RemoveAll(installPath); nil != err {
if err := filelock.Remove(installPath); nil != err {
logging.LogErrorf("remove template [%s] failed: %s", installPath, err)
return errors.New("remove community template failed")
}

View file

@ -26,6 +26,7 @@ import (
"github.com/dustin/go-humanize"
ants "github.com/panjf2000/ants/v2"
"github.com/siyuan-note/filelock"
"github.com/siyuan-note/httpclient"
"github.com/siyuan-note/logging"
"github.com/siyuan-note/siyuan/kernel/util"
@ -174,7 +175,7 @@ func InstallWidget(repoURL, repoHash, installPath string, systemID string) error
}
func UninstallWidget(installPath string) error {
if err := os.RemoveAll(installPath); nil != err {
if err := filelock.Remove(installPath); nil != err {
logging.LogErrorf("remove widget [%s] failed: %s", installPath, err)
return errors.New("remove community widget failed")
}

View file

@ -671,7 +671,7 @@ func RemoveUnusedAssets() (ret []string) {
for _, unusedAsset := range unusedAssets {
if unusedAsset = filepath.Join(util.DataDir, unusedAsset); filelock.IsExist(unusedAsset) {
if err := os.RemoveAll(unusedAsset); nil != err {
if err := filelock.Remove(unusedAsset); nil != err {
logging.LogErrorf("remove unused asset [%s] failed: %s", unusedAsset, err)
}
}
@ -709,7 +709,7 @@ func RemoveUnusedAsset(p string) (ret string) {
sql.BatchRemoveAssetsQueue([]string{hash})
}
if err = os.RemoveAll(absPath); nil != err {
if err = filelock.Remove(absPath); nil != err {
logging.LogErrorf("remove unused asset [%s] failed: %s", absPath, err)
}
ret = absPath

View file

@ -120,7 +120,7 @@ func ListNotebooks() (ret []*Box, err error) {
}
if readErr = gulu.JSON.UnmarshalJSON(data, boxConf); nil != readErr {
logging.LogErrorf("parse box conf [%s] failed: %s", boxConfPath, readErr)
os.RemoveAll(boxConfPath)
filelock.Remove(boxConfPath)
continue
}
}

View file

@ -161,7 +161,7 @@ func resetDuplicateBlocksOnFileSys() {
if info.IsDir() {
if boxPath == path {
// 跳过根路径(笔记本文件夹
// 跳过笔记本文件夹
return nil
}
@ -172,14 +172,6 @@ func resetDuplicateBlocksOnFileSys() {
if !ast.IsNodeIDPattern(info.Name()) {
return nil
}
if util.IsEmptyDir(filepath.Join(path)) {
// 删除空的子文档文件夹
if removeErr := os.RemoveAll(path); nil != removeErr {
logging.LogErrorf("remove empty folder failed: %s", removeErr)
}
return nil
}
return nil
}
@ -283,7 +275,7 @@ func recreateTree(tree *parse.Tree, absPath string) {
}
}
if err := os.RemoveAll(absPath); nil != err {
if err := filelock.Remove(absPath); nil != err {
logging.LogWarnf("remove [%s] failed: %s", absPath, err)
return
}
@ -411,7 +403,7 @@ func reindexTreeByUpdated(rootUpdatedMap, dbRootUpdatedMap map[string]string) {
}
var rootIDs []string
for rootID, _ := range dbRootUpdatedMap {
for rootID := range dbRootUpdatedMap {
if _, ok := rootUpdatedMap[rootID]; !ok {
rootIDs = append(rootIDs, rootID)
}

View file

@ -1,7 +1,6 @@
package model
import (
"os"
"path/filepath"
"runtime/debug"
"strings"
@ -128,7 +127,7 @@ func LoadAssetsTexts() {
util.AssetsTextsLock.Lock()
if err = gulu.JSON.UnmarshalJSON(data, &util.AssetsTexts); nil != err {
logging.LogErrorf("unmarshal assets texts failed: %s", err)
if err = os.RemoveAll(assetsTextsPath); nil != err {
if err = filelock.Remove(assetsTextsPath); nil != err {
logging.LogErrorf("removed corrupted assets texts failed: %s", err)
}
return