[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

@ -121,6 +121,12 @@ func (p *ProcessingEmoji) loadStatic(ctx context.Context) error {
return p.err
}
defer func() {
if err := stored.Close(); err != nil {
log.Errorf("loadStatic: error closing stored full size: %s", err)
}
}()
// we haven't processed a static version of this emoji yet so do it now
static, err := deriveStaticEmoji(stored, p.emoji.ImageContentType)
if err != nil {
@ -129,12 +135,6 @@ func (p *ProcessingEmoji) loadStatic(ctx context.Context) error {
return p.err
}
if err := stored.Close(); err != nil {
p.err = fmt.Errorf("loadStatic: error closing stored full size: %s", err)
atomic.StoreInt32(&p.staticState, int32(errored))
return p.err
}
// put the static in storage
if err := p.storage.Put(ctx, p.emoji.ImageStaticPath, static.small); err != nil {
p.err = fmt.Errorf("loadStatic: error storing static: %s", err)