|
@@ -57,18 +57,25 @@ import (
|
|
"github.com/studio-b12/gowebdav"
|
|
"github.com/studio-b12/gowebdav"
|
|
)
|
|
)
|
|
|
|
|
|
-func init() {
|
|
|
|
- subscribeRepoEvents()
|
|
|
|
-}
|
|
|
|
|
|
+func GetRepoFile(fileID string) (ret []byte, p string, err error) {
|
|
|
|
+ if 1 > len(Conf.Repo.Key) {
|
|
|
|
+ err = errors.New(Conf.Language(26))
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
|
|
-type Snapshot struct {
|
|
|
|
- *dejavu.Log
|
|
|
|
- TypesCount []*TypeCount `json:"typesCount"`
|
|
|
|
-}
|
|
|
|
|
|
+ repo, err := newRepository()
|
|
|
|
+ if nil != err {
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
|
|
-type TypeCount struct {
|
|
|
|
- Type string `json:"type"`
|
|
|
|
- Count int `json:"count"`
|
|
|
|
|
|
+ file, err := repo.GetFile(fileID)
|
|
|
|
+ if nil != err {
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ ret, err = repo.OpenFile(file)
|
|
|
|
+ p = file.Path
|
|
|
|
+ return
|
|
}
|
|
}
|
|
|
|
|
|
func OpenRepoSnapshotDoc(fileID string) (content string, isProtyleDoc bool, updated int64, err error) {
|
|
func OpenRepoSnapshotDoc(fileID string) (content string, isProtyleDoc bool, updated int64, err error) {
|
|
@@ -327,6 +334,16 @@ func parseTreeInSnapshot(data []byte, luteEngine *lute.Lute) (isProtyleDoc bool,
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+type Snapshot struct {
|
|
|
|
+ *dejavu.Log
|
|
|
|
+ TypesCount []*TypeCount `json:"typesCount"`
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+type TypeCount struct {
|
|
|
|
+ Type string `json:"type"`
|
|
|
|
+ Count int `json:"count"`
|
|
|
|
+}
|
|
|
|
+
|
|
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) {
|
|
@@ -1570,6 +1587,10 @@ func newRepository() (ret *dejavu.Repo, err error) {
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+func init() {
|
|
|
|
+ subscribeRepoEvents()
|
|
|
|
+}
|
|
|
|
+
|
|
func subscribeRepoEvents() {
|
|
func subscribeRepoEvents() {
|
|
eventbus.Subscribe(eventbus.EvtIndexBeforeWalkData, func(context map[string]interface{}, path string) {
|
|
eventbus.Subscribe(eventbus.EvtIndexBeforeWalkData, func(context map[string]interface{}, path string) {
|
|
msg := fmt.Sprintf(Conf.Language(158), path)
|
|
msg := fmt.Sprintf(Conf.Language(158), path)
|