MCPcopy Create free account
hub / github.com/castai/openwebui-content-sync / getFileContent

Method getFileContent

internal/adapter/github.go:179–203  ·  view source on GitHub ↗

getFileContent retrieves the actual content of a file

(ctx context.Context, owner, repo string, content *github.RepositoryContent)

Source from the content-addressed store, hash-verified

177
178// getFileContent retrieves the actual content of a file
179func (g *GitHubAdapter) getFileContent(ctx context.Context, owner, repo string, content *github.RepositoryContent) ([]byte, error) {
180 fileContent, err := content.GetContent()
181 if err != nil {
182 return nil, fmt.Errorf("failed to get content: %w", err)
183 }
184
185 if fileContent != "" {
186 // Content is already available (for small files)
187 return []byte(fileContent), nil
188 }
189
190 // For larger files, we need to download them
191 url := content.GetDownloadURL()
192 if url == "" {
193 return nil, fmt.Errorf("no download URL available for file")
194 }
195
196 resp, err := g.client.Client().Get(url)
197 if err != nil {
198 return nil, fmt.Errorf("failed to download file: %w", err)
199 }
200 defer resp.Body.Close()
201
202 return io.ReadAll(resp.Body)
203}
204
205// isTextFile checks if a file is likely to be a text file
206func isTextFile(filename string) bool {

Callers 1

processContentMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected