Fix: unclosed file after get thumbnails
This commit is contained in:
parent
ee08821361
commit
bf0998f3a5
2 changed files with 2 additions and 4 deletions
|
@ -52,6 +52,7 @@ func (fs *FileSystem) GenerateThumbnail(ctx context.Context, file *model.File) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
defer source.Close()
|
||||||
|
|
||||||
image, err := thumb.NewThumbFromFile(source, file.Name)
|
image, err := thumb.NewThumbFromFile(source, file.Name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -69,10 +69,7 @@ func (handler Handler) Put(ctx context.Context, file io.ReadCloser, dst string,
|
||||||
util.Log().Warning("无法创建文件,%s", err)
|
util.Log().Warning("无法创建文件,%s", err)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
defer func() {
|
defer out.Close()
|
||||||
err := out.Close()
|
|
||||||
fmt.Print(err)
|
|
||||||
}()
|
|
||||||
|
|
||||||
// 写入文件内容
|
// 写入文件内容
|
||||||
_, err = io.Copy(out, file)
|
_, err = io.Copy(out, file)
|
||||||
|
|
Loading…
Add table
Reference in a new issue