mirror of
https://github.com/mattermost/mattermost.git
synced 2026-08-08 20:18:09 -05:00
* Propagate context through Extractor.Extract Adds ctx context.Context to the Extractor interface and all implementations so callers can cancel in-flight extractions. pdfExtractor passes the context down to GetPlainText(ctx), which checks ctx.Done() at each page boundary. When extractWithTimeout fires (deadline exceeded or parent cancel), it cancels the derived context via defer cancel(), and the PDF goroutine stops at the next page rather than running to completion, eliminating the heap growth that caused OOM on complex documents. For non-context-aware extractors (docconv, plain, archive) the context is accepted but not yet acted on; they continue to run to completion on a detached goroutine after the timeout, as before. The call site in channels/app/file.go passes rctx.Context() so request cancellation (e.g. HTTP disconnect) also propagates. * Use new mattermost/pdf fork * Update notice reflecting the new fork * Fail archiveExtractor.Extract early on ctx errors * Bump mattermost/pdf to cd8a834041c4 --------- Co-authored-by: Mattermost Build <build@mattermost.com>
17 lines
405 B
Go
17 lines
405 B
Go
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
// See LICENSE.txt for license information.
|
|
|
|
package docextractor
|
|
|
|
import (
|
|
"context"
|
|
"io"
|
|
)
|
|
|
|
// Extractors define the interface needed to extract file content
|
|
type Extractor interface {
|
|
Match(filename string) bool
|
|
Extract(ctx context.Context, filename string, file io.ReadSeeker, maxFileSize int64) (string, error)
|
|
Name() string
|
|
}
|