mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-21 09:00:12 +01:00
This commit is contained in:
parent
3491683f4f
commit
6c1bfd791b
3 changed files with 50 additions and 0 deletions
|
|
@ -26,6 +26,31 @@ import (
|
||||||
"github.com/siyuan-note/siyuan/kernel/util"
|
"github.com/siyuan-note/siyuan/kernel/util"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func diffRepoSnapshots(c *gin.Context) {
|
||||||
|
ret := gulu.Ret.NewResult()
|
||||||
|
defer c.JSON(http.StatusOK, ret)
|
||||||
|
|
||||||
|
arg, ok := util.JsonArg(c, ret)
|
||||||
|
if !ok {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
left := arg["left"].(string)
|
||||||
|
right := arg["right"].(string)
|
||||||
|
adds, updates, removes, err := model.DiffRepoSnapshots(left, right)
|
||||||
|
if nil != err {
|
||||||
|
ret.Code = -1
|
||||||
|
ret.Msg = err.Error()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
ret.Data = map[string]interface{}{
|
||||||
|
"adds": adds,
|
||||||
|
"updates": updates,
|
||||||
|
"removes": removes,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func getCloudSpace(c *gin.Context) {
|
func getCloudSpace(c *gin.Context) {
|
||||||
ret := gulu.Ret.NewResult()
|
ret := gulu.Ret.NewResult()
|
||||||
defer c.JSON(http.StatusOK, ret)
|
defer c.JSON(http.StatusOK, ret)
|
||||||
|
|
|
||||||
|
|
@ -297,6 +297,7 @@ func ServeAPI(ginServer *gin.Engine) {
|
||||||
ginServer.Handle("POST", "/api/repo/removeCloudRepoTagSnapshot", model.CheckAuth, removeCloudRepoTagSnapshot)
|
ginServer.Handle("POST", "/api/repo/removeCloudRepoTagSnapshot", model.CheckAuth, removeCloudRepoTagSnapshot)
|
||||||
ginServer.Handle("POST", "/api/repo/uploadCloudSnapshot", model.CheckAuth, uploadCloudSnapshot)
|
ginServer.Handle("POST", "/api/repo/uploadCloudSnapshot", model.CheckAuth, uploadCloudSnapshot)
|
||||||
ginServer.Handle("POST", "/api/repo/downloadCloudSnapshot", model.CheckAuth, downloadCloudSnapshot)
|
ginServer.Handle("POST", "/api/repo/downloadCloudSnapshot", model.CheckAuth, downloadCloudSnapshot)
|
||||||
|
ginServer.Handle("POST", "/api/repo/diffRepoSnapshots", model.CheckAuth, diffRepoSnapshots)
|
||||||
|
|
||||||
ginServer.Handle("POST", "/api/notification/pushMsg", model.CheckAuth, pushMsg)
|
ginServer.Handle("POST", "/api/notification/pushMsg", model.CheckAuth, pushMsg)
|
||||||
ginServer.Handle("POST", "/api/notification/pushErrMsg", model.CheckAuth, pushErrMsg)
|
ginServer.Handle("POST", "/api/notification/pushErrMsg", model.CheckAuth, pushErrMsg)
|
||||||
|
|
|
||||||
|
|
@ -64,6 +64,30 @@ type TypeCount struct {
|
||||||
Count int `json:"count"`
|
Count int `json:"count"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func DiffRepoSnapshots(left, right string) (adds, updates, removes []*entity.File, err error) {
|
||||||
|
if 1 > len(Conf.Repo.Key) {
|
||||||
|
err = errors.New(Conf.Language(26))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
repo, err := newRepository()
|
||||||
|
if nil != err {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
leftIndex, err := repo.GetIndex(left)
|
||||||
|
if nil != err {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
rightIndex, err := repo.GetIndex(right)
|
||||||
|
if nil != err {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
adds, updates, removes, err = repo.DiffIndex(leftIndex, rightIndex)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
func GetRepoSnapshots(page int) (ret []*Snapshot, pageCount, totalCount int, err error) {
|
func GetRepoSnapshots(page int) (ret []*Snapshot, pageCount, totalCount int, err error) {
|
||||||
ret = []*Snapshot{}
|
ret = []*Snapshot{}
|
||||||
if 1 > len(Conf.Repo.Key) {
|
if 1 > len(Conf.Repo.Key) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue