mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-17 07:00:12 +01:00
This commit is contained in:
parent
5b308d2817
commit
dbbfaa4af5
9 changed files with 83 additions and 7 deletions
|
|
@ -872,6 +872,8 @@
|
|||
"136": "Initializing data repository key...",
|
||||
"137": "Failed to initialize data repository key",
|
||||
"138": "Data repository key is set",
|
||||
"139": "Data snapshot is being generated, [%s] data files have been processed, [%s] remaining..."
|
||||
"139": "Data snapshot is being generated, [%s] data files have been processed, [%s] remaining...",
|
||||
"140": "Failed to create data snapshot",
|
||||
"141": "Failed to rollback data snapshot"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -872,6 +872,8 @@
|
|||
"136": "Initialisation de la clé du référentiel de données...",
|
||||
"137": "Échec de l'initialisation de la clé du référentiel de données",
|
||||
"138": "La clé du référentiel de données est définie",
|
||||
"139": "L'instantané des données est en cours de génération, [%s] fichiers de données ont été traités, [%s] restants..."
|
||||
"139": "L'instantané des données est en cours de génération, [%s] fichiers de données ont été traités, [%s] restants...",
|
||||
"140": "Échec de la création de l'instantané des données",
|
||||
"141": "Échec de la restauration de l'instantané des données"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -871,6 +871,8 @@
|
|||
"136": "初始化數據倉庫密鑰...",
|
||||
"137": "初始化數據倉庫密鑰失敗",
|
||||
"138": "數據倉庫密鑰設置完畢",
|
||||
"139": "正在生成數據快照,已處理 [%s] 個數據文件,剩餘待處理 [%s]..."
|
||||
"139": "正在生成數據快照,已處理 [%s] 個數據文件,剩餘待處理 [%s]...",
|
||||
"140": "創建數據快照失敗",
|
||||
"141": "回滾數據快照失敗"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -873,6 +873,8 @@
|
|||
"136": "初始化数据仓库密钥...",
|
||||
"137": "初始化数据仓库密钥失败",
|
||||
"138": "数据仓库密钥设置完毕",
|
||||
"139": "正在生成数据快照,已处理 [%s] 个数据文件,剩余待处理 [%s]..."
|
||||
"139": "正在生成数据快照,已处理 [%s] 个数据文件,剩余待处理 [%s]...",
|
||||
"140": "创建数据快照失败",
|
||||
"141": "回滚数据快照失败"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,6 +27,27 @@ import (
|
|||
"github.com/siyuan-note/siyuan/kernel/util"
|
||||
)
|
||||
|
||||
func getRepoFile(c *gin.Context) {
|
||||
|
||||
}
|
||||
|
||||
func checkoutRepo(c *gin.Context) {
|
||||
ret := gulu.Ret.NewResult()
|
||||
defer c.JSON(http.StatusOK, ret)
|
||||
|
||||
arg, ok := util.JsonArg(c, ret)
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
|
||||
id := arg["id"].(string)
|
||||
if err := model.CheckoutRepo(id); nil != err {
|
||||
ret.Code = -1
|
||||
ret.Msg = model.Conf.Language(141)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
func getRepoIndexLogs(c *gin.Context) {
|
||||
ret := gulu.Ret.NewResult()
|
||||
defer c.JSON(http.StatusOK, ret)
|
||||
|
|
@ -60,7 +81,7 @@ func indexRepo(c *gin.Context) {
|
|||
message := arg["message"].(string)
|
||||
if err := model.IndexRepo(message); nil != err {
|
||||
ret.Code = -1
|
||||
ret.Msg = model.Conf.Language(137)
|
||||
ret.Msg = model.Conf.Language(140)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -249,7 +249,9 @@ func ServeAPI(ginServer *gin.Engine) {
|
|||
ginServer.Handle("POST", "/api/repo/initRepoKey", model.CheckAuth, initRepoKey)
|
||||
ginServer.Handle("POST", "/api/repo/importRepoKey", model.CheckAuth, importRepoKey)
|
||||
ginServer.Handle("POST", "/api/repo/indexRepo", model.CheckAuth, indexRepo)
|
||||
ginServer.Handle("POST", "/api/repo/checkoutRepo", model.CheckAuth, checkoutRepo)
|
||||
ginServer.Handle("POST", "/api/repo/getRepoIndexLogs", model.CheckAuth, getRepoIndexLogs)
|
||||
ginServer.Handle("POST", "/api/repo/getRepoFile", model.CheckAuth, getRepoFile)
|
||||
|
||||
ginServer.Handle("POST", "/api/notification/pushMsg", model.CheckAuth, pushMsg)
|
||||
ginServer.Handle("POST", "/api/notification/pushErrMsg", model.CheckAuth, pushErrMsg)
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ require (
|
|||
github.com/patrickmn/go-cache v2.1.0+incompatible
|
||||
github.com/qiniu/go-sdk/v7 v7.13.0
|
||||
github.com/radovskyb/watcher v1.0.7
|
||||
github.com/siyuan-note/dejavu v0.0.0-20220613134332-45af7919bc94
|
||||
github.com/siyuan-note/dejavu v0.0.0-20220613144035-412877c5ffa6
|
||||
github.com/siyuan-note/encryption v0.0.0-20220612074546-f1dd94fe8676
|
||||
github.com/vmihailenco/msgpack/v5 v5.3.5
|
||||
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673
|
||||
|
|
|
|||
|
|
@ -421,6 +421,8 @@ github.com/shurcooL/vfsgen v0.0.0-20200824052919-0d455de96546/go.mod h1:TrYk7fJV
|
|||
github.com/sirupsen/logrus v1.8.1/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0=
|
||||
github.com/siyuan-note/dejavu v0.0.0-20220613134332-45af7919bc94 h1:NRlFUCAFPEMWoBrvuEQ0csBUoyKvWtQ67g6ctGH5kVA=
|
||||
github.com/siyuan-note/dejavu v0.0.0-20220613134332-45af7919bc94/go.mod h1:pZFVF2imlfZMT5w6899ZwXCLKVccZ9GDJzdLHJ+ONik=
|
||||
github.com/siyuan-note/dejavu v0.0.0-20220613144035-412877c5ffa6 h1:YwbEqSGcdnS15HakNOZpCtI80rthjQM87FXHRsYIa6M=
|
||||
github.com/siyuan-note/dejavu v0.0.0-20220613144035-412877c5ffa6/go.mod h1:pZFVF2imlfZMT5w6899ZwXCLKVccZ9GDJzdLHJ+ONik=
|
||||
github.com/siyuan-note/encryption v0.0.0-20220612074546-f1dd94fe8676 h1:QB9TjJQFhXhZ6dAtPpY02DlzHAQm1C+WqZq6OadG8mI=
|
||||
github.com/siyuan-note/encryption v0.0.0-20220612074546-f1dd94fe8676/go.mod h1:H8fyqqAbp9XreANjeSbc72zEdFfKTXYN34tc1TjZwtw=
|
||||
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc=
|
||||
|
|
|
|||
|
|
@ -29,10 +29,20 @@ import (
|
|||
"github.com/siyuan-note/siyuan/kernel/util"
|
||||
)
|
||||
|
||||
func GetRepoFile(id string) (ret []byte, err error) {
|
||||
//repo, err := dejavu.NewRepo(util.DataDir, util.RepoDir, Conf.Repo.Key)
|
||||
//if nil != err {
|
||||
// util.LogErrorf("init repo failed: %s", err)
|
||||
// return
|
||||
//}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
func GetRepoIndexLogs(page int) (logs []*dejavu.Log, err error) {
|
||||
repo, err := dejavu.NewRepo(util.DataDir, util.RepoDir, Conf.Repo.Key)
|
||||
if nil != err {
|
||||
util.LogErrorf("new repo failed: %s", err)
|
||||
util.LogErrorf("init repo failed: %s", err)
|
||||
return
|
||||
}
|
||||
|
||||
|
|
@ -93,6 +103,38 @@ func InitRepoKey() (err error) {
|
|||
return
|
||||
}
|
||||
|
||||
var checkoutCallbacks = map[string]dejavu.Callback{
|
||||
"walkData": func(context, arg interface{}, err error) {
|
||||
context.(func(msg string))(arg.(string))
|
||||
},
|
||||
"upsertFile": func(context, arg interface{}, err error) {
|
||||
context.(func(msg string))(arg.(*entity.File).Path)
|
||||
},
|
||||
"removeFile": func(context, arg interface{}, err error) {
|
||||
context.(func(msg string))(arg.(*entity.File).Path)
|
||||
},
|
||||
}
|
||||
|
||||
func CheckoutRepo(id string) (err error) {
|
||||
if 1 > len(Conf.Repo.Key) {
|
||||
err = errors.New("repo key is nil")
|
||||
return
|
||||
}
|
||||
|
||||
repo, err := dejavu.NewRepo(util.DataDir, util.RepoDir, Conf.Repo.Key)
|
||||
if nil != err {
|
||||
util.LogErrorf("init repo failed: %s", err)
|
||||
return
|
||||
}
|
||||
|
||||
syncLock.Lock()
|
||||
defer syncLock.Unlock()
|
||||
filesys.ReleaseAllFileLocks()
|
||||
err = repo.Checkout(id, util.PushEndlessProgress, checkoutCallbacks)
|
||||
util.PushClearProgress()
|
||||
return
|
||||
}
|
||||
|
||||
var indexCallbacks = map[string]dejavu.Callback{
|
||||
"walkData": func(context, arg interface{}, err error) {
|
||||
context.(func(msg string))(arg.(string))
|
||||
|
|
@ -113,6 +155,7 @@ func IndexRepo(message string) (err error) {
|
|||
|
||||
repo, err := dejavu.NewRepo(util.DataDir, util.RepoDir, Conf.Repo.Key)
|
||||
if nil != err {
|
||||
util.LogErrorf("init repo failed: %s", err)
|
||||
return
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue