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

Method GitPull

controllers/BookController.go:977–1005  ·  view source on GitHub ↗

从Git仓库拉取书籍

()

Source from the content-addressed store, hash-verified

975
976// 从Git仓库拉取书籍
977func (this *BookController) GitPull() {
978 //处理步骤
979 //1、接受上传上来的zip文件,并存放到store/temp目录下
980 //2、解压zip到当前目录,然后移除非图片文件
981 //3、将文件夹移动到uploads目录下
982
983 identify := this.GetString("identify")
984
985 if !models.NewBook().HasProjectAccess(identify, this.Member.MemberId, conf.BookEditor) {
986 this.JsonResult(1, "无操作权限")
987 }
988
989 book, _ := models.NewBookResult().FindByIdentify(identify, this.Member.MemberId)
990 if book.BookId == 0 {
991 this.JsonResult(1, "导入失败,只有书籍创建人才有权限导入书籍")
992 }
993 //GitHub书籍链接
994 link := this.GetString("link")
995 go func() {
996 folder := "store/" + identify
997 err := utils.GitClone(link, folder)
998 if err != nil {
999 beego.Error(err.Error())
1000 }
1001 this.loadByFolder(book.BookId, identify, folder)
1002 }()
1003
1004 this.JsonResult(0, "提交成功,请耐心等待。")
1005}
1006
1007// 上传书籍
1008func (this *BookController) UploadProject() {

Callers

nothing calls this directly

Calls 7

loadByFolderMethod · 0.95
NewBookFunction · 0.92
NewBookResultFunction · 0.92
GitCloneFunction · 0.92
HasProjectAccessMethod · 0.80
JsonResultMethod · 0.80
FindByIdentifyMethod · 0.45

Tested by

no test coverage detected