从Git仓库拉取书籍
()
| 975 | |
| 976 | // 从Git仓库拉取书籍 |
| 977 | func (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 | // 上传书籍 |
| 1008 | func (this *BookController) UploadProject() { |
nothing calls this directly
no test coverage detected