Modify: close file in main routine

This commit is contained in:
HFO4
2019-12-11 18:52:41 +08:00
parent d0bb123e03
commit 18968458a4
7 changed files with 30 additions and 5 deletions

View File

@@ -11,6 +11,7 @@ import (
"github.com/HFO4/cloudreve/pkg/util"
"github.com/HFO4/cloudreve/service/explorer"
"github.com/gin-gonic/gin"
"io"
"net/http"
"net/url"
"strconv"
@@ -99,6 +100,11 @@ func Thumb(c *gin.Context) {
}
http.ServeContent(c.Writer, c.Request, "thumb.png", fs.FileTarget[0].UpdatedAt, resp.Content)
// 检查是否需要关闭文件
if fc, ok := resp.Content.(io.Closer); ok {
defer fc.Close()
}
}
// Download 文件下载