mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-18 15:40:12 +01:00
🎨 Improve update tx
This commit is contained in:
parent
1fde0611c3
commit
7e2d2bfe37
1 changed files with 10 additions and 4 deletions
|
|
@ -18,6 +18,7 @@ package model
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"sort"
|
"sort"
|
||||||
|
|
@ -696,11 +697,12 @@ func (tx *Transaction) doDelete(operation *Operation) (ret *TxErr) {
|
||||||
var err error
|
var err error
|
||||||
id := operation.ID
|
id := operation.ID
|
||||||
tree, err := tx.loadTree(id)
|
tree, err := tx.loadTree(id)
|
||||||
if ErrBlockNotFound == err {
|
if nil != err {
|
||||||
return nil // move 以后这里会空,算作正常情况
|
if errors.Is(err, ErrBlockNotFound) {
|
||||||
|
// move 以后这里会空,算作正常情况
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if nil != err {
|
|
||||||
msg := fmt.Sprintf("load tree [%s] failed: %s", id, err)
|
msg := fmt.Sprintf("load tree [%s] failed: %s", id, err)
|
||||||
logging.LogErrorf(msg)
|
logging.LogErrorf(msg)
|
||||||
return &TxErr{code: TxErrCodeBlockNotFound, id: id}
|
return &TxErr{code: TxErrCodeBlockNotFound, id: id}
|
||||||
|
|
@ -926,6 +928,10 @@ func (tx *Transaction) doUpdate(operation *Operation) (ret *TxErr) {
|
||||||
|
|
||||||
tree, err := tx.loadTree(id)
|
tree, err := tx.loadTree(id)
|
||||||
if nil != err {
|
if nil != err {
|
||||||
|
if errors.Is(err, ErrBlockNotFound) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
logging.LogErrorf("load tree [%s] failed: %s", id, err)
|
logging.LogErrorf("load tree [%s] failed: %s", id, err)
|
||||||
return &TxErr{code: TxErrCodeBlockNotFound, id: id}
|
return &TxErr{code: TxErrCodeBlockNotFound, id: id}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue