MCPcopy Index your code
hub / github.com/TruthHun/BookStack / GetVersionContent

Method GetVersionContent

models/version_control.go:64–87  ·  view source on GitHub ↗

获取版本数据

(isHtml bool)

Source from the content-addressed store, hash-verified

62
63// 获取版本数据
64func (v *versionControl) GetVersionContent(isHtml bool) (content string) {
65 file := v.MdFile
66 if isHtml {
67 file = v.HtmlFile
68 }
69 if utils.StoreType == utils.StoreLocal { //本地存储
70 b, err := ioutil.ReadFile(file)
71 if err == nil {
72 content = string(b)
73 }
74 } else { // OSS 存储
75 bucket, err := store.NewOss().GetBucket()
76 if err != nil {
77 beego.Error(err.Error())
78 return
79 }
80 reader, err := bucket.GetObject(strings.TrimLeft(file, "./"))
81 if err == nil {
82 b, _ := ioutil.ReadAll(reader)
83 content = string(b)
84 }
85 }
86 return
87}
88
89// 删除版本文件
90func (v *versionControl) DeleteVersion() (err error) {

Callers 2

CompareMethod · 0.80
RestoreMethod · 0.80

Calls 3

NewOssFunction · 0.92
stringFunction · 0.85
GetBucketMethod · 0.80

Tested by

no test coverage detected