mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-17 15:10:12 +01:00
🎨 Improve rollback doc file history https://github.com/siyuan-note/siyuan/issues/11575
This commit is contained in:
parent
8ba87a340f
commit
69d0f20501
2 changed files with 12 additions and 2 deletions
|
|
@ -271,6 +271,11 @@ func RollbackDocHistory(boxID, historyPath string) (err error) {
|
||||||
|
|
||||||
FullReindex()
|
FullReindex()
|
||||||
IncSync()
|
IncSync()
|
||||||
|
go func() {
|
||||||
|
sql.WaitForWritingDatabase()
|
||||||
|
// 刷新关联的动态锚文本 https://github.com/siyuan-note/siyuan/issues/11575
|
||||||
|
refreshDynamicRefText(tree.Root, tree)
|
||||||
|
}()
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -36,6 +36,7 @@ var (
|
||||||
operationQueue []*dbQueueOperation
|
operationQueue []*dbQueueOperation
|
||||||
dbQueueLock = sync.Mutex{}
|
dbQueueLock = sync.Mutex{}
|
||||||
txLock = sync.Mutex{}
|
txLock = sync.Mutex{}
|
||||||
|
isWriting = false
|
||||||
)
|
)
|
||||||
|
|
||||||
type dbQueueOperation struct {
|
type dbQueueOperation struct {
|
||||||
|
|
@ -77,7 +78,7 @@ func isWritingDatabase() bool {
|
||||||
time.Sleep(util.SQLFlushInterval + 50*time.Millisecond)
|
time.Sleep(util.SQLFlushInterval + 50*time.Millisecond)
|
||||||
dbQueueLock.Lock()
|
dbQueueLock.Lock()
|
||||||
defer dbQueueLock.Unlock()
|
defer dbQueueLock.Unlock()
|
||||||
if 0 < len(operationQueue) {
|
if 0 < len(operationQueue) || isWriting {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
|
|
@ -103,7 +104,11 @@ func FlushQueue() {
|
||||||
}
|
}
|
||||||
|
|
||||||
txLock.Lock()
|
txLock.Lock()
|
||||||
defer txLock.Unlock()
|
isWriting = true
|
||||||
|
defer func() {
|
||||||
|
isWriting = false
|
||||||
|
txLock.Unlock()
|
||||||
|
}()
|
||||||
|
|
||||||
start := time.Now()
|
start := time.Now()
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue