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
```
This commit is contained in:
Agniva De Sarker
2022-07-26 12:17:23 +05:30
committed by GitHub
parent 77881fc357
commit 7441a26b6d
2 changed files with 15 additions and 0 deletions
+5
View File
@@ -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")
+10
View File
@@ -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))
}