Documentation
¶
Overview ¶
Package filesearch indexes the files of volumes, which are folders, of their metadata, content and artwork, and searches them, in a SQLite database, which it creates, and which is swept of what's gone, when a volume is indexed again.
Index ¶
- Constants
- Variables
- type Manager
- func (m *Manager) Artwork(ctx context.Context, id int64) (_ []byte, err error)
- func (m *Manager) Close() error
- func (m *Manager) DeleteVolume(ctx context.Context, id int64) (_ *schema.Volume, err error)
- func (m *Manager) GetObject(ctx context.Context, path string) (_ *schema.Object, err error)
- func (m *Manager) GetVolume(ctx context.Context, id int64) (_ *schema.Volume, err error)
- func (m *Manager) IndexVolume(ctx context.Context, req schema.IndexVolumeRequest, fn ProgressFn) (_ *schema.Volume, err error)
- func (m *Manager) ListObjects(ctx context.Context, req schema.ObjectListRequest) (_ *schema.ObjectList, err error)
- func (m *Manager) ListVolumes(ctx context.Context, req schema.VolumeListRequest) (_ *schema.VolumeList, err error)
- func (m *Manager) Markdown(ctx context.Context, id int64) (_ string, err error)
- func (m *Manager) ObjectPath(ctx context.Context, object *schema.Object) (string, error)
- func (m *Manager) Ping(ctx context.Context) error
- func (m *Manager) Progress(volume int64) (schema.Progress, error)
- func (m *Manager) VolumeByPath(ctx context.Context, path string) (_ *schema.Volume, err error)
- type Opt
- type ProgressFn
Constants ¶
const ( // MaxText is the most of a file's content, as Markdown, which is read, // and searched, in bytes MaxText = 256 * 1024 // ArtworkSize is the largest width or height of a file's artwork, in // pixels ArtworkSize = 256 )
Variables ¶
var DefaultExclude = []string{
`^\.`,
`^~\$`,
`~$`,
`^#.*#$`,
`(?i)\.(tmp|temp|swp|swo|part|crdownload|download)$`,
`(?i)^(thumbs\.db|desktop\.ini|ehthumbs\.db)$`,
`(?i)^(\$recycle\.bin|system volume information|lost\+found)$`,
`^(node_modules|__pycache__)$`,
`\.pyc$`,
}
DefaultExclude are the names of files and folders which aren't indexed, unless WithoutDefaultExclude is an option: hidden files and folders, such as .git and .DS_Store, Office's lock files, editors' backups and autosaves, temporary files and partial downloads, the files and folders of Windows and of file systems, and the folders of dependencies and builds
Functions ¶
This section is empty.
Types ¶
type Manager ¶
type Manager struct {
// The progress of the volumes which are indexing, or were, by their paths
sync.Mutex
// contains filtered or unexported fields
}
Manager indexes and searches the files of volumes, in its database
func New ¶
New returns a manager, of the database of the path, which is created when it doesn't exist, or sqlite.Memory, and creates its schema, when it hasn't it.
func (*Manager) Artwork ¶
Artwork returns an object's artwork, such as a thumbnail or a cover, by its id, which is ErrNotFound when it hasn't any
func (*Manager) DeleteVolume ¶
DeleteVolume deletes a volume, by its id, with its objects, and their text, and returns it, which is ErrNotFound when there isn't one, and ErrConflict when this manager is indexing it
func (*Manager) GetObject ¶
GetObject returns the object of a path: of its volume's path, and its own, or its own, or the end of it, after a /, such as a file's name. It's ErrNotFound when no object is, and ErrConflict, of their paths, when more than one is.
func (*Manager) GetVolume ¶
GetVolume returns a volume, by its id, with the status of its indexing, which is ErrNotFound when there isn't one
func (*Manager) IndexVolume ¶
func (m *Manager) IndexVolume(ctx context.Context, req schema.IndexVolumeRequest, fn ProgressFn) (_ *schema.Volume, err error)
IndexVolume indexes a volume, of a folder, which is added, when it isn't one already. Its run walks it, of its folders, when the request is recursive, and marks each file which is as it was, of its size and when it was modified, and indexes those which are new, or changed. Once it's indexed, the objects which the run didn't see are swept. A file which can't be read isn't indexed, and its error is said to the function.
The function, when it isn't nil, is called with its progress, and the errors of files which can't be read, and when it's finished.
It returns the volume, which is indexed, or failed, with its error, such as when the context is done. A volume which this manager is indexing is ErrConflict.
func (*Manager) ListObjects ¶
func (m *Manager) ListObjects(ctx context.Context, req schema.ObjectListRequest) (_ *schema.ObjectList, err error)
ListObjects lists the objects, of the volumes, or all of them, by their paths, or searches them, when there's a query, the best first, with the request, and the limit which was used, clamped to what's returned
func (*Manager) ListVolumes ¶
func (m *Manager) ListVolumes(ctx context.Context, req schema.VolumeListRequest) (_ *schema.VolumeList, err error)
ListVolumes lists the volumes, by their paths, with the status of their indexing, with the request, and the limit which was used, clamped to what's returned
func (*Manager) Markdown ¶
Markdown returns an object's content, as Markdown, by its id, which is read from its file, as it isn't kept, all of it, with go-metadata's handlers which are imported. It's ErrNotFound when the object isn't, and empty when the file has no content.
func (*Manager) ObjectPath ¶
ObjectPath returns the path of an object's file, of its volume's path, and its own
type Opt ¶
type Opt func(*opt) error
Opt is an option of a manager, when it's created
func WithExclude ¶
WithExclude excludes the files, and folders, whose names match the regular expressions, such as `\.bak$`, as well as DefaultExclude. An excluded folder's files aren't indexed, and what's excluded which was indexed is swept, when its volume is indexed again.
func WithMaxReaders ¶
WithMaxReaders sets the most connections which read the database at once, such as to search it, while it's indexed
func WithReader ¶
WithReader sets what reads files, as a fingerprint, such as of the versions of filesearch and go-metadata, and the handlers which a program imports. A volume whose last complete run was of another reader, or of none, has all of its files indexed again, as they can be read differently, rather than those which are new, or changed.
func WithTMDB ¶
WithTMDB looks up the movies and episodes on TMDB which videos are, of their names, with the client, so their titles, dates, descriptions and posters are TMDB's. A video is looked up when it's indexed, which is when it's new, or changed.
func WithTracer ¶
WithTracer sets the OpenTelemetry tracer, of the spans of the manager, and of its database's queries
func WithoutDefaultExclude ¶
func WithoutDefaultExclude() Opt
WithoutDefaultExclude doesn't exclude DefaultExclude, so hidden files, and the others, are indexed, unless WithExclude excludes them
type ProgressFn ¶
ProgressFn is called as a volume is indexed: with its progress, after each file is indexed, or marked, and with an error, when a file can't be read, which isn't indexed, and once it's finished, with its error, when it failed. It's called as the volume is walked, so it delays it.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package cmd is the commands, and flags, of a file search manager, which a program composes, and which imports the handlers of go-metadata which it reads files with.
|
Package cmd is the commands, and flags, of a file search manager, which a program composes, and which imports the handlers of go-metadata which it reads files with. |
|
filesearch
command
|
|
|
Package schema is the schema of the file indexer: its tables, its queries, and the types which are read from, and written to, them.
|
Package schema is the schema of the file indexer: its tables, its queries, and the types which are read from, and written to, them. |
|
Package test creates managers for tests, of temporary databases, which are closed, and deleted, when the tests end.
|
Package test creates managers for tests, of temporary databases, which are closed, and deleted, when the tests end. |