summaryrefslogtreecommitdiff
path: root/internal/media/manager.go
diff options
context:
space:
mode:
authorLibravatar tsmethurst <tobi.smethurst@protonmail.com>2022-01-04 17:37:54 +0100
committerLibravatar tsmethurst <tobi.smethurst@protonmail.com>2022-01-04 17:37:54 +0100
commit7ebe0f6a15f1881e465b8e78bb8ef8b4982b00aa (patch)
treee8ddc08aa2eb8df937438fb72dd99690a9e81a6a /internal/media/manager.go
parentreturn very partial image on first upload (diff)
downloadgotosocial-7ebe0f6a15f1881e465b8e78bb8ef8b4982b00aa.tar.xz
start working on thumb + full funcs
Diffstat (limited to 'internal/media/manager.go')
-rw-r--r--internal/media/manager.go17
1 files changed, 8 insertions, 9 deletions
diff --git a/internal/media/manager.go b/internal/media/manager.go
index 54b964564..074ebdb58 100644
--- a/internal/media/manager.go
+++ b/internal/media/manager.go
@@ -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)
}