Documentation
¶
Index ¶
- Constants
- Variables
- func GitReadArgs(ctx context.Context, runner worktree.StreamingGitRunner, root, command string, ...) ([]string, error)
- func InlineMediaType(path string) (mime string, inline bool)
- func OpenRegularFile(root *os.Root, path string) (*os.File, error)
- func Sensitive(path string) bool
- func ValidatePath(path string) error
- type Content
- type ContentKind
- type Entry
- type EntryKind
- type FileReader
- func (r *FileReader) List(ctx context.Context, root Root, dir string, opts ListOptions) (listing Listing, err error)
- func (r *FileReader) Open(ctx context.Context, root Root, path string) (OpenedFile, error)
- func (r *FileReader) Read(ctx context.Context, root Root, path string, opts ReadOptions) (content Content, err error)
- type FileSearch
- type FindMatch
- type FindResult
- type Finder
- type GitStatus
- type ListOptions
- type Listing
- type OpenedFile
- type Option
- type ReadOptions
- type Reader
- type Root
- type RootKind
- type RootRef
- type RootResolver
- type SearchFile
- type SearchMatch
- type SearchQuery
- type SearchResult
- type Searcher
Constants ¶
const ( TextLimit = 1 << 20 ImageLimit = 5 << 20 EntryLimit = 5000 )
const FindIndexLimit = 200000
Variables ¶
var ( ErrInvalidPath = errors.New("projectfiles: invalid path") ErrPathOutsideRoot = errors.New("projectfiles: path outside root") ErrPathDenied = errors.New("projectfiles: path denied") ErrNotFound = errors.New("projectfiles: not found") ErrNotADirectory = errors.New("projectfiles: not a directory") ErrNotAFile = errors.New("projectfiles: not a file") ErrRootNotFound = errors.New("projectfiles: root not found") ErrSensitive = errors.New("projectfiles: sensitive file") )
var ErrInvalidQuery = errors.New("projectfiles: invalid query")
Functions ¶
func GitReadArgs ¶
func GitReadArgs( ctx context.Context, runner worktree.StreamingGitRunner, root, command string, args ...string, ) ([]string, error)
GitReadArgs applies the shared read-only policy, discovering filter drivers afresh on each call.
func InlineMediaType ¶
InlineMediaType names the response type for raw file bytes by extension alone, never by sniffing. inline is false for every type outside the allowlist, which downloads as octets.
func OpenRegularFile ¶
OpenRegularFile confines the open and rejects special descriptors even after a path swap.
func ValidatePath ¶
Types ¶
type ContentKind ¶
type ContentKind string
const ( ContentKindText ContentKind = "text" ContentKindImage ContentKind = "image" ContentKindBinary ContentKind = "binary" ContentKindSensitive ContentKind = "sensitive" )
type FileReader ¶
type FileReader struct {
// contains filtered or unexported fields
}
func NewReader ¶
func NewReader(opts ...Option) *FileReader
func (*FileReader) List ¶
func (r *FileReader) List(ctx context.Context, root Root, dir string, opts ListOptions) (listing Listing, err error)
func (*FileReader) Open ¶
func (r *FileReader) Open(ctx context.Context, root Root, path string) (OpenedFile, error)
Open returns a seekable handle on one confined regular file for streaming. Sensitive files are refused outright because a byte stream has no reveal step. The caller closes Content.
func (*FileReader) Read ¶
func (r *FileReader) Read(ctx context.Context, root Root, path string, opts ReadOptions) (content Content, err error)
type FileSearch ¶
type FileSearch struct {
// contains filtered or unexported fields
}
func NewSearch ¶
func NewSearch(runner worktree.StreamingGitRunner, opts ...workspacefiles.Option) *FileSearch
func (*FileSearch) Find ¶
func (s *FileSearch) Find(ctx context.Context, root Root, query string, limit int) (FindResult, error)
func (*FileSearch) Search ¶
func (s *FileSearch) Search(ctx context.Context, root Root, q SearchQuery) (SearchResult, error)
type FindResult ¶
type ListOptions ¶
type ListOptions struct{ ShowIgnored, Refresh bool }
type OpenedFile ¶
OpenedFile is a confined regular file opened for streaming; the caller closes Content.
type Option ¶
type Option func(*FileReader)
func WithGitRunner ¶
func WithGitRunner(runner worktree.StreamingGitRunner) Option
func WithStatusTTL ¶
WithStatusTTL sets status retention; zero disables retention while keeping coalescing.
type ReadOptions ¶
type ReadOptions struct{ Reveal bool }
type Root ¶
func CanonicalRoot ¶
type SearchFile ¶
type SearchFile struct {
Path string
Matches []SearchMatch
TruncatedMatches bool
}
type SearchMatch ¶
type SearchQuery ¶
type SearchResult ¶
type SearchResult struct {
Files []SearchFile
TotalFiles, TotalMatches int
Truncated, TimedOut bool
SensitiveExcluded int
Engine string
}
type Searcher ¶
type Searcher interface {
Search(context.Context, Root, SearchQuery) (SearchResult, error)
}