修复BUG

This commit is contained in:
Minho
2017-06-05 13:41:47 +08:00
parent 8a4eabd158
commit 95c63fb1fb
2 changed files with 12 additions and 12 deletions

View File

@@ -21,11 +21,11 @@ import (
"github.com/astaxie/beego/orm" "github.com/astaxie/beego/orm"
"github.com/boombuler/barcode" "github.com/boombuler/barcode"
"github.com/boombuler/barcode/qr" "github.com/boombuler/barcode/qr"
"github.com/lifei6671/godoc/commands"
"github.com/lifei6671/godoc/conf" "github.com/lifei6671/godoc/conf"
"github.com/lifei6671/godoc/models" "github.com/lifei6671/godoc/models"
"github.com/lifei6671/godoc/utils" "github.com/lifei6671/godoc/utils"
"github.com/lifei6671/godoc/utils/wkhtmltopdf" "github.com/lifei6671/godoc/utils/wkhtmltopdf"
"github.com/lifei6671/godoc/commands"
) )
//DocumentController struct. //DocumentController struct.
@@ -546,7 +546,7 @@ func (c *DocumentController) DownloadAttachment() {
if attachment.BookId != book_id { if attachment.BookId != book_id {
c.Abort("404") c.Abort("404")
} }
c.Ctx.Output.Download(strings.Join(commands.WorkingDirectory,attachment.FilePath), attachment.FileName) c.Ctx.Output.Download(filepath.Join(commands.WorkingDirectory, attachment.FilePath), attachment.FileName)
c.StopRun() c.StopRun()
} }
@@ -587,7 +587,7 @@ func (c *DocumentController) RemoveAttachment() {
beego.Error(err) beego.Error(err)
c.JsonResult(6005, "删除失败") c.JsonResult(6005, "删除失败")
} }
os.Remove(strings.Join(commands.WorkingDirectory,attach.FilePath)) os.Remove(filepath.Join(commands.WorkingDirectory, attach.FilePath))
c.JsonResult(0, "ok", attach) c.JsonResult(0, "ok", attach)
} }

View File

@@ -4,11 +4,11 @@ package models
import ( import (
"time" "time"
"os"
"github.com/astaxie/beego"
"github.com/astaxie/beego/orm" "github.com/astaxie/beego/orm"
"github.com/lifei6671/godoc/conf" "github.com/lifei6671/godoc/conf"
"os"
"github.com/astaxie/beego"
"strings"
) )
// Attachment struct . // Attachment struct .