🐛 Uninstalling plugins, widgets and templates may cause data sync errors https://github.com/siyuan-note/siyuan/issues/10324
This commit is contained in:
parent
fe9e261feb
commit
745c9bcf99
7 changed files with 14 additions and 12 deletions
|
@ -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")
|
||||
}
|
||||
|
|
|
@ -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")
|
||||
}
|
||||
|
|
|
@ -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")
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
|
@ -173,9 +173,9 @@ func resetDuplicateBlocksOnFileSys() {
|
|||
return nil
|
||||
}
|
||||
|
||||
if util.IsEmptyDir(filepath.Join(path)) {
|
||||
if util.IsEmptyDir(path) {
|
||||
// 删除空的子文档文件夹
|
||||
if removeErr := os.RemoveAll(path); nil != removeErr {
|
||||
if removeErr := filelock.Remove(path); nil != removeErr {
|
||||
logging.LogErrorf("remove empty folder failed: %s", removeErr)
|
||||
}
|
||||
return nil
|
||||
|
@ -283,7 +283,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 +411,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)
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue