Skip to content

Commit

Permalink
🎨 Improve data snapshot comparison #8081
Browse files Browse the repository at this point in the history
  • Loading branch information
88250 committed Apr 22, 2023
1 parent 0dcca1e commit a2fae4d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
3 changes: 2 additions & 1 deletion kernel/api/repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func openRepoSnapshotDoc(c *gin.Context) {
}

id := arg["id"].(string)
id, rootID, content, isLargeDoc, err := model.OpenRepoSnapshotDoc(id)
id, rootID, content, isLargeDoc, updated, err := model.OpenRepoSnapshotDoc(id)
if nil != err {
ret.Code = -1
ret.Msg = err.Error()
Expand All @@ -48,6 +48,7 @@ func openRepoSnapshotDoc(c *gin.Context) {
"rootID": rootID,
"content": content,
"isLargeDoc": isLargeDoc,
"updated": updated,
}
}

Expand Down
8 changes: 5 additions & 3 deletions kernel/model/repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ type TypeCount struct {
Count int `json:"count"`
}

func OpenRepoSnapshotDoc(fileID string) (id, rootID, content string, isLargeDoc bool, err error) {
func OpenRepoSnapshotDoc(fileID string) (id, rootID, content string, isLargeDoc bool, updated int64, err error) {
if 1 > len(Conf.Repo.Key) {
err = errors.New(Conf.Language(26))
return
Expand All @@ -80,7 +80,7 @@ func OpenRepoSnapshotDoc(fileID string) (id, rootID, content string, isLargeDoc
return
}
luteEngine := NewLute()
isLargeDoc, snapshotTree, err := parseTreeInSnapshot(fileID, repo, luteEngine)
isLargeDoc, snapshotTree, updated, err := parseTreeInSnapshot(fileID, repo, luteEngine)
if nil != err {
logging.LogErrorf("parse tree from snapshot file [%s] failed", fileID)
return
Expand Down Expand Up @@ -270,7 +270,7 @@ func parseTitleInSnapshot(fileID string, repo *dejavu.Repo, luteEngine *lute.Lut
return
}

func parseTreeInSnapshot(fileID string, repo *dejavu.Repo, luteEngine *lute.Lute) (isLargeDoc bool, tree *parse.Tree, err error) {
func parseTreeInSnapshot(fileID string, repo *dejavu.Repo, luteEngine *lute.Lute) (isLargeDoc bool, tree *parse.Tree, updated int64, err error) {
file, err := repo.GetFile(fileID)
if nil != err {
return
Expand All @@ -286,6 +286,8 @@ func parseTreeInSnapshot(fileID string, repo *dejavu.Repo, luteEngine *lute.Lute
if nil != err {
return
}

updated = file.Updated
return
}

Expand Down

0 comments on commit a2fae4d

Please sign in to comment.