start working on thumb + full funcs

This commit is contained in:
tsmethurst 2022-01-04 17:37:54 +01:00
commit 7ebe0f6a15
3 changed files with 147 additions and 32 deletions

View file

@ -81,23 +81,22 @@ func (m *manager) ProcessMedia(ctx context.Context, data []byte, accountID strin
switch mainType {
case mimeImage:
if !supportedImage(contentType) {
return nil, fmt.Errorf("image type %s not supported", contentType)
}
if len(data) == 0 {
return nil, errors.New("image was of size 0")
}
media, err := m.preProcessImage(ctx, data, contentType, accountID)
if err != nil {
return nil, err
}
m.pool.Enqueue(func(innerCtx context.Context) {
select {
case <-innerCtx.Done():
// if the inner context is done that means the worker pool is closing, so we should just return
return
default:
media.PreLoad(innerCtx)
}
})
return nil, nil
return media, nil
default:
return nil, fmt.Errorf("content type %s not (yet) supported", contentType)
}