mirror of
https://github.com/mattermost/mattermost.git
synced 2026-09-21 14:20:41 +08:00
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:
@@ -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")
|
||||
|
||||
@@ -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))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user