index

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2024 License: GPL-3.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ContentTypeVideo
	ContentTypeImage
	ContentTypeOther
	ContentTypeDir
)

Variables

View Source
var (
	ErrSemaphoreAcquire = errors.New("failed to acquire the semaphore")
	ErrFileLoad         = errors.New("failed to load file")
	ErrPreviewPull      = errors.New("failed to preview")
)
View Source
var (
	ErrInvalidHeader       = errors.New("invalid header")
	ErrReadHeader          = errors.New("failed to read header")
	ErrReadMetaItemsCount  = errors.New("failed to read meta items count")
	ErrReadMetaPartSize    = errors.New("failed to read meta's part size")
	ErrReadMetaPart        = errors.New("failed to read meta items")
	ErrMetaItemDecode      = errors.New("failed to decode meta's item")
	ErrReadBinaryData      = errors.New("failed to read binary data")
	ErrWriteHeader         = errors.New("failed to write header")
	ErrWriteMetaItemsCount = errors.New("failed to write meta items count")
	ErrEncodeMetaItem      = errors.New("failed to encode meta's item")
	ErrWriteMetaPartSize   = errors.New("failed to write meta's part size")
	ErrWriteMetaPart       = errors.New("failed to write meta items")
	ErrWriteBinaryData     = errors.New("failed to write binary data")

	ErrJSONEncode       = errors.New("failed to JSON encode item")
	ErrGZIPDecode       = errors.New("failed to decode gzip")
	ErrGZIPDecoderClose = errors.New("failed to close gzip decoder")
	ErrGZIPEncode       = errors.New("failed to encode gzip")
	ErrGZIPEncoderClose = errors.New("failed to close gzip encoder")

	ErrMetaDecode = errors.New("failed to decode meta data")
	ErrMetaEncode = errors.New("failed to encode meta data")
)
View Source
var ErrNotFound = errors.New("not found")

Functions

This section is empty.

Types

type FileMeta

type FileMeta interface {
	Path() string
	RelativePath() string
	Name() string
	ModTime() time.Time
	IsDir() bool
	Size() int64
}

type ID added in v1.1.0

type ID string

type Index

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

func NewIndex

func NewIndex(ctx context.Context, r io.Reader, opts ...Option) (Index, error)

func (*Index) Decode

func (index *Index) Decode(r io.Reader) error

func (*Index) Encode

func (index *Index) Encode(w io.Writer) (uint64, error)

func (*Index) FilesWithPreviewStat

func (index *Index) FilesWithPreviewStat() (int, int, uint32)

func (*Index) OutDated

func (index *Index) OutDated() bool

func (*Index) Pull

func (index *Index) Pull(id ID) (*Meta, error)

func (*Index) PullChildren

func (index *Index) PullChildren(id ID) ([]*Meta, error)

func (*Index) PullPaths

func (index *Index) PullPaths(id ID) ([]*Meta, error)

func (*Index) PullPreview

func (index *Index) PullPreview(id ID) ([]byte, error)

func (*Index) Search

func (index *Index) Search(query string, dirID ID) []*Meta

type Meta

type Meta struct {
	ID           ID              `json:"id"`
	AbsolutePath Path            `json:"absolutePath"`
	RelativePath RelativePath    `json:"relativePath"`
	OriginSize   int64           `json:"originSize"`
	Name         string          `json:"name"`
	ModTime      time.Time       `json:"modTime"`
	IsDir        bool            `json:"isDir"`
	Preview      PreviewLocation `json:"preview"`
	Duration     time.Duration   `json:"duration"`
	Resolution   Resolution      `json:"resolution"`
	Extension    string          `json:"extension"`
	Type         int             `json:"type"`
}

func (*Meta) IsAnimatedImage added in v1.2.0

func (m *Meta) IsAnimatedImage() bool

func (*Meta) IsImage

func (m *Meta) IsImage() bool

func (*Meta) IsOtherFile

func (m *Meta) IsOtherFile() bool

func (*Meta) IsVideo

func (m *Meta) IsVideo() bool

func (*Meta) Path

func (m *Meta) Path() string

func (*Meta) Size added in v1.1.0

func (m *Meta) Size() int64

type Option

type Option func(*indexBuilder)

func WithFiles

func WithFiles(files []FileMeta) Option

func WithNewFiles

func WithNewFiles(f func()) Option

func WithPreview

func WithPreview(gen PreviewGenerator) Option

func WithProgress

func WithProgress(f func()) Option

func WithWorkers

func WithWorkers(w int) Option

type Path added in v1.1.0

type Path string

type PreviewGenerator

type PreviewGenerator interface {
	Pull(item preview.Source) (preview.Data, error)
}

type PreviewLocation added in v1.1.0

type PreviewLocation struct {
	Length uint32 `json:"length"`
	Offset uint32 `json:"offset"`
}

type RelativePath added in v1.1.0

type RelativePath string

type Resolution added in v1.2.0

type Resolution struct {
	Width  int `json:"width"`
	Height int `json:"height"`
}

Jump to

Keyboard shortcuts

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