source

package
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 26, 2026 License: Apache-2.0 Imports: 19 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package source reads the files of a knowledge collection. A scan keeps the captured root open and never follows a link out of it.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Lines

func Lines(text string) []string

Lines counts lines as a terminator-separated sequence.

Types

type Document

type Document struct {
	Path, Revision string
	ModifiedMs     uint64
	Stat           Stat
	Parts          []Part
}

Document is one extracted file.

type Entry

type Entry struct {
	Document  *Document
	Path      string
	Cached    bool
	Reason    string
	Excluded  bool
	Failed    bool
	Directory bool
}

Entry is one scanned file: an extracted Document, a file whose stamp the index still holds (Cached), or a skipped path with its Reason. Excluded skips are protected or ignored paths and are not counted. Failed marks a path that could not be read now and may be readable later, unlike a skip, which its content decides; Directory tells that everything below it was not visited.

type OCR

type OCR struct {
	Signature func() ([32]byte, error)
	Parts     func(ctx context.Context, name string, data []byte) ([]office.Part, error)
}

OCR reads images and scanned PDF pages. Signature identifies the selected model, or is zero when OCR is not configured.

type Part

type Part struct {
	Title, Text string
	Position    protocol.KnowledgePosition
}

Part is one positioned text of a document.

type Scan

type Scan struct {
	// contains filtered or unexported fields
}

Scan walks one source depth first.

func Controller

func Controller(ctx context.Context, kind, path string) (*Scan, error)

Controller scans a directory or file a controller registered by its absolute path. Locators keep the registered spelling.

func Within

func Within(ctx context.Context, root, relative string) (*Scan, error)

Within scans a current descendant of a registered controller directory.

func Worktree

func Worktree(ctx context.Context, root, relative string) (*Scan, error)

Worktree scans a path below the root of a captured worktree.

func (*Scan) Close

func (scan *Scan) Close()

Close releases the directories a scan still holds.

func (*Scan) Next

func (scan *Scan) Next(reuse func(path string, stat Stat) (bool, error), watch func([]Watch)) (*Entry, error)

Next returns the next entry, or nil at the end. reuse reports a file whose stamp the index still holds; watch receives directories as they are found, before their files are read.

func (*Scan) SetOCR

func (scan *Scan) SetOCR(ocr *OCR)

SetOCR lets the scan read images and scanned PDF pages.

func (*Scan) TakeWatches

func (scan *Scan) TakeWatches() []Watch

TakeWatches returns the directories discovered since the last call.

type Stat

type Stat struct {
	Size            uint64
	ModifiedSeconds uint64
	ModifiedNanos   uint32
	// Extractor identifies the OCR model for files it reads, zeros otherwise.
	Extractor [32]byte
}

Stat is the metadata witness that lets an unchanged file skip extraction.

type Watch

type Watch struct {
	Relative string
	// contains filtered or unexported fields
}

Watch tells which entries of one scanned directory matter to the index.

func (Watch) Accepts

func (watch Watch) Accepts(name string, directory bool) bool

Accepts reports whether a change of name in the directory needs a rescan.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL