From 7441a26b6d6a67c62797c3a0ebdda86327a51591 Mon Sep 17 00:00:00 2001 From: Agniva De Sarker Date: Tue, 26 Jul 2022 12:17:23 +0530 Subject: [PATCH] MM-45871: Do not try to extract content from images (#20698) This creates faulty requests to Bifrost and results in errors and warnings in the logs. Even without Bifrost, this would make unnecessary requests to S3. We only extract info from documents and therefore we can safely avoid this. ```release-note NONE ``` --- app/file.go | 5 +++++ app/file_test.go | 10 ++++++++++ 2 files changed, 15 insertions(+) diff --git a/app/file.go b/app/file.go index 9d7a382563..12c954de33 100644 --- a/app/file.go +++ b/app/file.go @@ -1327,6 +1327,11 @@ func (a *App) SearchFilesInTeamForUser(c *request.Context, terms string, userId } func (a *App) ExtractContentFromFileInfo(fileInfo *model.FileInfo) error { + // We don't process images. + if fileInfo.IsImage() { + return nil + } + file, aerr := a.FileReader(fileInfo.Path) if aerr != nil { return errors.Wrap(aerr, "failed to open file for extract file content") diff --git a/app/file_test.go b/app/file_test.go index d234e5eb83..6f84894b8f 100644 --- a/app/file_test.go +++ b/app/file_test.go @@ -543,3 +543,13 @@ func TestSearchFilesInTeamForUser(t *testing.T) { es.AssertExpectations(t) }) } + +func TestExtractContentFromFileInfo(t *testing.T) { + app := &App{} + fi := &model.FileInfo{ + MimeType: "image/jpeg", + } + + // Test that we don't process images. + require.NoError(t, app.ExtractContentFromFileInfo(fi)) +}