mirror of
https://github.com/mindoc-org/mindoc.git
synced 2025-05-03 12:37:47 +08:00
fix:修复链接文章的附件无法下载问题
This commit is contained in:
parent
11634d8c5b
commit
34487947ba
@ -632,16 +632,18 @@ func (c *BlogController) Download() {
|
||||
attachment, err := models.NewAttachment().Find(attachId)
|
||||
|
||||
if err != nil {
|
||||
beego.Error("DownloadAttachment => ", err)
|
||||
if err == orm.ErrNoRows {
|
||||
c.ShowErrorPage(404, "附件不存在")
|
||||
} else {
|
||||
beego.Error("查询附件时出现异常 -> ", err)
|
||||
c.ShowErrorPage(500, "查询附件时出现异常")
|
||||
}
|
||||
}
|
||||
if blog.BlogType == 1 && attachment.BookId != blog.BookId && attachment.DocumentId != blog.DocumentId {
|
||||
|
||||
//如果是链接的文章,需要校验文档ID是否一致,如果不是,需要保证附件的项目ID为0且文档的ID等于博文ID
|
||||
if blog.BlogType == 1 && attachment.DocumentId != blog.DocumentId {
|
||||
c.ShowErrorPage(404, "附件不存在")
|
||||
} else if attachment.BookId != 0 || attachment.DocumentId != blogId {
|
||||
} else if blog.BlogType != 1 && (attachment.BookId != 0 || attachment.DocumentId != blogId ) {
|
||||
c.ShowErrorPage(404, "附件不存在")
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user