Fix: unclosed file after get thumbnails

This commit is contained in:
HFO4 2020-01-01 20:17:50 +08:00
parent ee08821361
commit bf0998f3a5
2 changed files with 2 additions and 4 deletions

View file

@ -52,6 +52,7 @@ func (fs *FileSystem) GenerateThumbnail(ctx context.Context, file *model.File) {
if err != nil {
return
}
defer source.Close()
image, err := thumb.NewThumbFromFile(source, file.Name)
if err != nil {

View file

@ -69,10 +69,7 @@ func (handler Handler) Put(ctx context.Context, file io.ReadCloser, dst string,
util.Log().Warning("无法创建文件,%s", err)
return err
}
defer func() {
err := out.Close()
fmt.Print(err)
}()
defer out.Close()
// 写入文件内容
_, err = io.Copy(out, file)