Full Mattermost server source with integrated Community Enterprise features. Includes vendor directory for offline/air-gapped builds. Structure: - enterprise-impl/: Enterprise feature implementations - enterprise-community/: Init files that register implementations - enterprise/: Bridge imports (community_imports.go) - vendor/: All dependencies for offline builds Build (online): go build ./cmd/mattermost Build (offline/air-gapped): go build -mod=vendor ./cmd/mattermost 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
51 lines
1.1 KiB
Go
51 lines
1.1 KiB
Go
package docconv
|
|
|
|
import (
|
|
"fmt"
|
|
"io"
|
|
"os"
|
|
)
|
|
|
|
// LocalFile is a type which wraps an *os.File. See NewLocalFile for more details.
|
|
type LocalFile struct {
|
|
*os.File
|
|
|
|
unlink bool
|
|
}
|
|
|
|
// NewLocalFile ensures that there is a file which contains the data provided by r. If r is
|
|
// actually an instance of *os.File then this file is used, otherwise a temporary file is
|
|
// created and the data from r copied into it. Callers must call Done() when
|
|
// the LocalFile is no longer needed to ensure all resources are cleaned up.
|
|
func NewLocalFile(r io.Reader) (*LocalFile, error) {
|
|
if f, ok := r.(*os.File); ok {
|
|
return &LocalFile{
|
|
File: f,
|
|
}, nil
|
|
}
|
|
|
|
f, err := os.CreateTemp(os.TempDir(), "docconv")
|
|
if err != nil {
|
|
return nil, fmt.Errorf("error creating temporary file: %v", err)
|
|
}
|
|
_, err = io.Copy(f, r)
|
|
if err != nil {
|
|
f.Close()
|
|
os.Remove(f.Name())
|
|
return nil, fmt.Errorf("error copying data into temporary file: %v", err)
|
|
}
|
|
|
|
return &LocalFile{
|
|
File: f,
|
|
unlink: true,
|
|
}, nil
|
|
}
|
|
|
|
// Done cleans up all resources.
|
|
func (l *LocalFile) Done() {
|
|
l.Close()
|
|
if l.unlink {
|
|
os.Remove(l.Name())
|
|
}
|
|
}
|