core

package
v1.2.4 Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2022 License: MIT Imports: 22 Imported by: 2

Documentation

Index

Constants

View Source
const (
	MDBStrategyAllPublic             = "all_public"
	MDBStrategyPublicOrSmallInMerkaz = "public_or_small_in_merkaz"
	MDBStrategyPreferredLanguage     = "preferred_language"
)

Variables

This section is empty.

Functions

func CleanupTestConfig added in v1.2.2

func CleanupTestConfig() error

func HumanizeBytes added in v1.2.0

func HumanizeBytes(b int64) string

HumanizeBytes format the given number of bytes for easier human reading in SI units.

func Mkdirp added in v1.1.0

func Mkdirp(path string) error

Mkdirp creates all missing parent directories for the destination file path.

func NewTestConfig added in v1.2.2

func NewTestConfig()

func Sha1Sum

func Sha1Sum(path string) (string, error)

Types

type AllPublicStrategy added in v1.2.0

type AllPublicStrategy struct{}

type ChecksumTask

type ChecksumTask struct {
	Path     string
	Checksum string
	Err      error `json:"-"`
	FName    string
	FSize    int64
	FModTime int64
}

type Closer added in v1.1.0

type Closer interface {
	Close()
}

type CompletedChecksumTasks added in v1.2.2

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

func NewCompletedChecksumTasks added in v1.2.2

func NewCompletedChecksumTasks(root string) *CompletedChecksumTasks

func (*CompletedChecksumTasks) Close added in v1.2.2

func (cct *CompletedChecksumTasks) Close() error

type FileRecord

type FileRecord struct {
	Sha1      string
	MdbID     int64
	MdbSize   int64
	Size      int64
	ModTime   time.Time
	LocalCopy bool
}

func (*FileRecord) FromLine

func (r *FileRecord) FromLine(line string) error

func (*FileRecord) ToLine

func (r *FileRecord) ToLine(path string) string

type MDBFile added in v1.2.0

type MDBFile struct {
	ID            int64
	Sha1          string
	Name          string
	Type          string
	Language      string
	VideoSize     sql.NullString
	MimeType      sql.NullString
	ContentUnitID int64
	Size          int64
}

type MDBStrategy added in v1.2.0

type MDBStrategy interface {
	Augment(*sql.DB, map[string]*FileRecord) error
}

func MakeMDBStrategy added in v1.2.0

func MakeMDBStrategy(name, params string) (MDBStrategy, error)

func NewAllPublicStrategy added in v1.2.0

func NewAllPublicStrategy() MDBStrategy

func NewPreferredLanguageStrategy added in v1.2.0

func NewPreferredLanguageStrategy(Languages []string) MDBStrategy

func NewPublicOrSmallInMerkazStrategy added in v1.2.0

func NewPublicOrSmallInMerkazStrategy() MDBStrategy

func NewSimpleQueryStrategy added in v1.2.0

func NewSimpleQueryStrategy(query string) MDBStrategy

type MockSyncer added in v1.2.2

type MockSyncer struct {
	*SyncerImpl
	// contains filtered or unexported fields
}

func NewMockSyncer added in v1.2.2

func NewMockSyncer(testData *TestData) *MockSyncer

func (*MockSyncer) AugmentMDBToIndex added in v1.2.2

func (s *MockSyncer) AugmentMDBToIndex(idx map[string]*FileRecord) error

type PreferredLanguageStrategy added in v1.2.0

type PreferredLanguageStrategy struct {
	Languages []string
}

func (*PreferredLanguageStrategy) Augment added in v1.2.0

func (s *PreferredLanguageStrategy) Augment(db *sql.DB, idx map[string]*FileRecord) error

type PublicOrSmallInMerkazStrategy added in v1.2.0

type PublicOrSmallInMerkazStrategy struct{}

type Sha1FS

type Sha1FS struct {
	Root            string
	ScanReapWorkers int
}

func NewSha1FS

func NewSha1FS() *Sha1FS

func (*Sha1FS) IsExistValid

func (fs *Sha1FS) IsExistValid(checksum string) bool

func (*Sha1FS) Path

func (fs *Sha1FS) Path(checksum string) string

func (*Sha1FS) ReadIndex

func (fs *Sha1FS) ReadIndex() (map[string]*FileRecord, error)

func (*Sha1FS) ScanReap

func (fs *Sha1FS) ScanReap() error

func (*Sha1FS) WriteIndex

func (fs *Sha1FS) WriteIndex(idx map[string]*FileRecord) error

type SimpleQueryStrategy added in v1.2.0

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

func (*SimpleQueryStrategy) Augment added in v1.2.0

func (s *SimpleQueryStrategy) Augment(db *sql.DB, idx map[string]*FileRecord) error

type Syncer

type Syncer interface {
	GetFS() *Sha1FS
	DoSync()
	AugmentMDBToIndex(idx map[string]*FileRecord) error
}

func NewSyncer added in v1.1.0

func NewSyncer() Syncer

type SyncerImpl added in v1.1.0

type SyncerImpl struct {
	FS *Sha1FS
	// contains filtered or unexported fields
}

func (*SyncerImpl) AugmentMDBToIndex added in v1.1.0

func (s *SyncerImpl) AugmentMDBToIndex(idx map[string]*FileRecord) error

func (*SyncerImpl) Close added in v1.1.0

func (s *SyncerImpl) Close()

func (*SyncerImpl) DoSync added in v1.1.0

func (s *SyncerImpl) DoSync()

func (*SyncerImpl) GetFS added in v1.1.0

func (s *SyncerImpl) GetFS() *Sha1FS

func (*SyncerImpl) OnTaskComplete added in v1.1.0

func (s *SyncerImpl) OnTaskComplete(workerID int, task fetch.Task, resp interface{}, err error)

func (*SyncerImpl) OnTaskEnqueue added in v1.1.0

func (s *SyncerImpl) OnTaskEnqueue(task fetch.Task)

func (*SyncerImpl) OnTaskRun added in v1.1.0

func (s *SyncerImpl) OnTaskRun(workerID int, task fetch.Task)

type TestData added in v1.2.2

type TestData struct {
	SrcDir string
	Files  map[string]*TestFile
}

func (*TestData) Cleanup added in v1.2.2

func (d *TestData) Cleanup() error

type TestFile added in v1.2.2

type TestFile struct {
	FileRecord
	Path string
}

func MakeTestFile added in v1.2.2

func MakeTestFile(dir, name string, size int) (*TestFile, error)

Jump to

Keyboard shortcuts

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