mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-02-01 21:21:47 +01:00
🎨 使用第三方同步盘时弹出提示并退出内核 https://github.com/siyuan-note/siyuan/issues/7683
This commit is contained in:
parent
d7473b7a6d
commit
5f6d1eac9a
17 changed files with 69 additions and 171 deletions
|
|
@ -24,7 +24,6 @@ import (
|
|||
"github.com/88250/gulu"
|
||||
"github.com/88250/lute/html"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/siyuan-note/filelock"
|
||||
"github.com/siyuan-note/logging"
|
||||
"github.com/siyuan-note/siyuan/kernel/model"
|
||||
"github.com/siyuan-note/siyuan/kernel/util"
|
||||
|
|
@ -195,11 +194,12 @@ func checkBlockExist(c *gin.Context) {
|
|||
|
||||
id := arg["id"].(string)
|
||||
b, err := model.GetBlock(id, nil)
|
||||
if errors.Is(err, filelock.ErrUnableAccessFile) {
|
||||
ret.Code = 2
|
||||
ret.Data = id
|
||||
return
|
||||
}
|
||||
// TODO 文件被锁的情况已经在 filelock 中做了退出进程处理,不会走到应用层,所以 code 为 2 的情况应该移除
|
||||
//if errors.Is(err, filelock.ErrUnableAccessFile) {
|
||||
// ret.Code = 2
|
||||
// ret.Data = id
|
||||
// return
|
||||
//}
|
||||
if errors.Is(err, model.ErrIndexing) {
|
||||
ret.Code = 0
|
||||
ret.Data = false
|
||||
|
|
@ -405,11 +405,11 @@ func getBlockInfo(c *gin.Context) {
|
|||
id := arg["id"].(string)
|
||||
|
||||
tree, err := model.LoadTreeByID(id)
|
||||
if errors.Is(err, filelock.ErrUnableAccessFile) {
|
||||
ret.Code = 2
|
||||
ret.Data = id
|
||||
return
|
||||
}
|
||||
//if errors.Is(err, filelock.ErrUnableAccessFile) {
|
||||
// ret.Code = 2
|
||||
// ret.Data = id
|
||||
// return
|
||||
//}
|
||||
if errors.Is(err, model.ErrIndexing) {
|
||||
ret.Code = 3
|
||||
ret.Msg = model.Conf.Language(56)
|
||||
|
|
@ -438,11 +438,11 @@ func getBlockInfo(c *gin.Context) {
|
|||
}
|
||||
|
||||
root, err := model.GetBlock(block.RootID, tree)
|
||||
if errors.Is(err, filelock.ErrUnableAccessFile) {
|
||||
ret.Code = 2
|
||||
ret.Data = id
|
||||
return
|
||||
}
|
||||
//if errors.Is(err, filelock.ErrUnableAccessFile) {
|
||||
// ret.Code = 2
|
||||
// ret.Data = id
|
||||
// return
|
||||
//}
|
||||
if errors.Is(err, model.ErrIndexing) {
|
||||
ret.Code = 3
|
||||
ret.Data = model.Conf.Language(56)
|
||||
|
|
|
|||
|
|
@ -61,13 +61,7 @@ func appendBlock(c *gin.Context) {
|
|||
},
|
||||
}
|
||||
|
||||
err := model.PerformTransactions(&transactions)
|
||||
if nil != err {
|
||||
ret.Code = 1
|
||||
ret.Msg = err.Error()
|
||||
return
|
||||
}
|
||||
|
||||
model.PerformTransactions(&transactions)
|
||||
model.WaitForWritingFiles()
|
||||
|
||||
ret.Data = transactions
|
||||
|
|
@ -106,13 +100,7 @@ func prependBlock(c *gin.Context) {
|
|||
},
|
||||
}
|
||||
|
||||
err := model.PerformTransactions(&transactions)
|
||||
if nil != err {
|
||||
ret.Code = 1
|
||||
ret.Msg = err.Error()
|
||||
return
|
||||
}
|
||||
|
||||
model.PerformTransactions(&transactions)
|
||||
model.WaitForWritingFiles()
|
||||
|
||||
ret.Data = transactions
|
||||
|
|
@ -169,13 +157,7 @@ func insertBlock(c *gin.Context) {
|
|||
},
|
||||
}
|
||||
|
||||
err := model.PerformTransactions(&transactions)
|
||||
if nil != err {
|
||||
ret.Code = 1
|
||||
ret.Msg = err.Error()
|
||||
return
|
||||
}
|
||||
|
||||
model.PerformTransactions(&transactions)
|
||||
model.WaitForWritingFiles()
|
||||
|
||||
ret.Data = transactions
|
||||
|
|
@ -260,13 +242,7 @@ func updateBlock(c *gin.Context) {
|
|||
}
|
||||
}
|
||||
|
||||
err = model.PerformTransactions(&transactions)
|
||||
if nil != err {
|
||||
ret.Code = 1
|
||||
ret.Msg = err.Error()
|
||||
return
|
||||
}
|
||||
|
||||
model.PerformTransactions(&transactions)
|
||||
model.WaitForWritingFiles()
|
||||
|
||||
ret.Data = transactions
|
||||
|
|
@ -298,12 +274,7 @@ func deleteBlock(c *gin.Context) {
|
|||
},
|
||||
}
|
||||
|
||||
err := model.PerformTransactions(&transactions)
|
||||
if nil != err {
|
||||
ret.Code = 1
|
||||
ret.Msg = err.Error()
|
||||
return
|
||||
}
|
||||
model.PerformTransactions(&transactions)
|
||||
|
||||
ret.Data = transactions
|
||||
broadcastTransactions(transactions)
|
||||
|
|
|
|||
|
|
@ -17,7 +17,6 @@
|
|||
package api
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"path"
|
||||
|
|
@ -27,7 +26,6 @@ import (
|
|||
|
||||
"github.com/88250/gulu"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/siyuan-note/filelock"
|
||||
"github.com/siyuan-note/siyuan/kernel/filesys"
|
||||
"github.com/siyuan-note/siyuan/kernel/model"
|
||||
"github.com/siyuan-note/siyuan/kernel/util"
|
||||
|
|
@ -691,11 +689,11 @@ func getDoc(c *gin.Context) {
|
|||
}
|
||||
|
||||
blockCount, content, parentID, parent2ID, rootID, typ, eof, scroll, boxID, docPath, isBacklinkExpand, err := model.GetDoc(startID, endID, id, index, keyword, mode, size, isBacklink)
|
||||
if errors.Is(err, filelock.ErrUnableAccessFile) {
|
||||
ret.Code = 2
|
||||
ret.Data = id
|
||||
return
|
||||
}
|
||||
//if errors.Is(err, filelock.ErrUnableAccessFile) {
|
||||
// ret.Code = 2
|
||||
// ret.Data = id
|
||||
// return
|
||||
//}
|
||||
if model.ErrBlockNotFound == err {
|
||||
ret.Code = 3
|
||||
return
|
||||
|
|
|
|||
|
|
@ -17,14 +17,12 @@
|
|||
package api
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"github.com/88250/gulu"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/siyuan-note/filelock"
|
||||
"github.com/siyuan-note/siyuan/kernel/model"
|
||||
"github.com/siyuan-note/siyuan/kernel/util"
|
||||
)
|
||||
|
|
@ -61,10 +59,7 @@ func performTransactions(c *gin.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
if err = model.PerformTransactions(&transactions); errors.Is(err, filelock.ErrUnableAccessFile) {
|
||||
ret.Code = 1
|
||||
return
|
||||
}
|
||||
model.PerformTransactions(&transactions)
|
||||
|
||||
ret.Data = transactions
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue