🎨 Improve indexing completeness when exiting https://github.com/siyuan-note/siyuan/issues/12039
This commit is contained in:
parent
35dccde23a
commit
07d2930739
2 changed files with 10 additions and 4 deletions
|
@ -611,7 +611,7 @@ func Close(force, setCurrentWorkspace bool, execInstallPkg int) (exitCode int) {
|
|||
closeUserGuide()
|
||||
|
||||
// Improve indexing completeness when exiting https://github.com/siyuan-note/siyuan/issues/12039
|
||||
sql.WaitForWritingDatabase()
|
||||
sql.WaitForWritingDatabaseIn(200 * time.Millisecond)
|
||||
|
||||
util.IsExiting.Store(true)
|
||||
waitSecondForExecInstallPkg := false
|
||||
|
|
|
@ -61,7 +61,7 @@ func FlushTxJob() {
|
|||
func WaitForWritingDatabase() {
|
||||
var printLog bool
|
||||
var lastPrintLog bool
|
||||
for i := 0; isWritingDatabase(); i++ {
|
||||
for i := 0; isWritingDatabase(util.SQLFlushInterval + 50*time.Millisecond); i++ {
|
||||
time.Sleep(50 * time.Millisecond)
|
||||
if 200 < i && !printLog { // 10s 后打日志
|
||||
logging.LogWarnf("database is writing: \n%s", logging.ShortStack())
|
||||
|
@ -74,8 +74,14 @@ func WaitForWritingDatabase() {
|
|||
}
|
||||
}
|
||||
|
||||
func isWritingDatabase() bool {
|
||||
time.Sleep(util.SQLFlushInterval + 50*time.Millisecond)
|
||||
func WaitForWritingDatabaseIn(duration time.Duration) {
|
||||
for i := 0; isWritingDatabase(duration); i++ {
|
||||
time.Sleep(50 * time.Millisecond)
|
||||
}
|
||||
}
|
||||
|
||||
func isWritingDatabase(d time.Duration) bool {
|
||||
time.Sleep(d)
|
||||
dbQueueLock.Lock()
|
||||
defer dbQueueLock.Unlock()
|
||||
if 0 < len(operationQueue) || isWriting {
|
||||
|
|
Loading…
Add table
Reference in a new issue