summaryrefslogtreecommitdiff
path: root/internal/media/processingemoji.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/media/processingemoji.go')
-rw-r--r--internal/media/processingemoji.go14
1 files changed, 6 insertions, 8 deletions
diff --git a/internal/media/processingemoji.go b/internal/media/processingemoji.go
index e1c6f2efb..79bc23998 100644
--- a/internal/media/processingemoji.go
+++ b/internal/media/processingemoji.go
@@ -193,24 +193,22 @@ func (p *ProcessingEmoji) store(ctx context.Context) error {
return nil
}
- // execute the data function to get the reader out of it
- reader, fileSize, err := p.data(ctx)
+ // execute the data function to get the readcloser out of it
+ rc, fileSize, err := p.data(ctx)
if err != nil {
return fmt.Errorf("store: error executing data function: %s", err)
}
// defer closing the reader when we're done with it
defer func() {
- if rc, ok := reader.(io.ReadCloser); ok {
- if err := rc.Close(); err != nil {
- log.Errorf("store: error closing readcloser: %s", err)
- }
+ if err := rc.Close(); err != nil {
+ log.Errorf("store: error closing readcloser: %s", err)
}
}()
// extract no more than 261 bytes from the beginning of the file -- this is the header
firstBytes := make([]byte, maxFileHeaderBytes)
- if _, err := reader.Read(firstBytes); err != nil {
+ if _, err := rc.Read(firstBytes); err != nil {
return fmt.Errorf("store: error reading initial %d bytes: %s", maxFileHeaderBytes, err)
}
@@ -242,7 +240,7 @@ func (p *ProcessingEmoji) store(ctx context.Context) error {
p.emoji.ImageContentType = contentType
// concatenate the first bytes with the existing bytes still in the reader (thanks Mara)
- readerToStore := io.MultiReader(bytes.NewBuffer(firstBytes), reader)
+ readerToStore := io.MultiReader(bytes.NewBuffer(firstBytes), rc)
var maxEmojiSize int64
if p.emoji.Domain == "" {