[bugfix] Server and closer bugfixes (#839)

* defer streaming from storage more forcefully

* shut down Server more gracefully

* use command context as server BaseContext
This commit is contained in:
tobi 2022-09-19 13:43:22 +02:00 committed by GitHub
commit 3777f5c684
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 47 additions and 29 deletions

View file

@ -145,9 +145,7 @@ func (p *ProcessingMedia) loadThumb(ctx context.Context) error {
return p.err
}
// whatever happens, close the stream when we're done
defer func() {
log.Tracef("loadThumb: closing stored stream %s", p.attachment.URL)
if err := stored.Close(); err != nil {
log.Errorf("loadThumb: error closing stored full size: %s", err)
}
@ -210,6 +208,12 @@ func (p *ProcessingMedia) loadFullSize(ctx context.Context) error {
return p.err
}
defer func() {
if err := stored.Close(); err != nil {
log.Errorf("loadFullSize: error closing stored full size: %s", err)
}
}()
// decode the image
ct := p.attachment.File.ContentType
switch ct {
@ -227,12 +231,6 @@ func (p *ProcessingMedia) loadFullSize(ctx context.Context) error {
return p.err
}
if err := stored.Close(); err != nil {
p.err = fmt.Errorf("loadFullSize: error closing stored full size: %s", err)
atomic.StoreInt32(&p.fullSizeState, int32(errored))
return p.err
}
// set appropriate fields on the attachment based on the image we derived
p.attachment.FileMeta.Original = gtsmodel.Original{
Width: decoded.width,