bulkimport

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2026 License: GPL-3.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidPath = errors.New(
		"source path invalid (not absolute, doesn't exist, or not a directory)",
	)
	ErrPathOutsideLibrary = errors.New(
		"source path is outside library_path (in_place mode requires inside, rename mode requires outside)",
	)
	ErrScanRunning        = errors.New("another scan is already active")
	ErrScanNotFound       = errors.New("scan not found")
	ErrScanNotReviewable  = errors.New("scan is not in awaiting_review state")
	ErrScanNotCancellable = errors.New("scan is not in a cancellable state")
	ErrScanNotDeletable   = errors.New("scan must be cancelled before delete")
)

Functions

This section is empty.

Types

type Classification

type Classification struct {
	Kind            entimportscanfile.Classification
	Candidates      []schema.ScannedCandidate
	TMDBID          uint32
	ExistingMovieID uint32
}

Classification holds the matcher's decision for a single scanned file.

func Classify

func Classify(
	parsed library.ParseResult,
	hits []metadata.MovieResult,
	alreadyAdded map[uint32]uint32,
) Classification

Classify decides how a parsed filename + TMDB hits + existing-library lookup fall into one of the four buckets. Existing-row collision wins over confirmed or ambiguous because attaching to an existing row beats creating a duplicate.

type FilesParams

type FilesParams struct {
	ScanID         uint32
	Classification entimportscanfile.Classification // empty = all
	Query          string
	Page           uint16
	Limit          uint16
}

FilesParams is the input for Manager.Files.

type Manager

type Manager interface {
	StartScan(ctx context.Context, p StartScanParams) (*ent.ImportScan, error)
	Get(ctx context.Context, id uint32) (*ent.ImportScan, error)
	List(ctx context.Context, page, limit uint16) ([]*ent.ImportScan, uint32, error)
	Files(ctx context.Context, p FilesParams) ([]*ent.ImportScanFile, uint32, error)
	GetFile(ctx context.Context, scanID, fileID uint32) (*ent.ImportScanFile, error)
	UpdateFileDecision(
		ctx context.Context,
		scanID, fileID uint32,
		decision entimportscanfile.Decision,
		tmdbID *uint32,
	) (*ent.ImportScanFile, error)
	Cancel(ctx context.Context, id uint32) error
	Commit(ctx context.Context, id uint32) error
	Delete(ctx context.Context, id uint32) error
	AbortInflight(ctx context.Context) (uint32, error)
}

Manager is the consumer-facing interface for the bulk-import service.

type SeriesAdder

type SeriesAdder interface {
	Add(
		ctx context.Context,
		tvdbID uint32,
		qualityProfile string,
	) (*ent.TVShow, error)
}

SeriesAdder creates a TV show (with its seasons and episodes) from a TVDB id. Satisfied by *tvshow.Service; used to adopt shows on series-scan commit.

type Service

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

Service implements Manager.

func NewService

func NewService(
	store db.Store,
	meta metadata.Provider,
	importSvc *library.ImportService,
	movieSvc *movie.Service,
	seriesAdder SeriesAdder,
	posters posters.Manager,
	libraryDir string,
) *Service

NewService constructs the bulk-import service.

func (*Service) AbortInflight

func (s *Service) AbortInflight(ctx context.Context) (uint32, error)

AbortInflight is the boot-time helper. Called from wire.go before the HTTP server starts.

func (*Service) Cancel

func (s *Service) Cancel(ctx context.Context, id uint32) error

func (*Service) Commit

func (s *Service) Commit(ctx context.Context, id uint32) error

func (*Service) Delete

func (s *Service) Delete(ctx context.Context, id uint32) error

func (*Service) Files

func (s *Service) Files(
	ctx context.Context,
	p FilesParams,
) ([]*ent.ImportScanFile, uint32, error)

func (*Service) Get

func (s *Service) Get(ctx context.Context, id uint32) (*ent.ImportScan, error)

func (*Service) GetFile

func (s *Service) GetFile(
	ctx context.Context,
	scanID, fileID uint32,
) (*ent.ImportScanFile, error)

func (*Service) List

func (s *Service) List(
	ctx context.Context,
	page, limit uint16,
) ([]*ent.ImportScan, uint32, error)

func (*Service) StartScan

func (s *Service) StartScan(
	ctx context.Context,
	p StartScanParams,
) (*ent.ImportScan, error)

StartScan validates params, creates the ImportScan row, and kicks off the scan goroutine. The goroutine uses context.WithoutCancel because the originating HTTP request ends within milliseconds; cancellation flows through DB state.

func (*Service) UpdateFileDecision

func (s *Service) UpdateFileDecision(
	ctx context.Context,
	scanID, fileID uint32,
	decision entimportscanfile.Decision,
	tmdbID *uint32,
) (*ent.ImportScanFile, error)

type StartScanParams

type StartScanParams struct {
	SourcePath string
	Mode       entimportscan.Mode       // in_place | rename
	ImportMode entimportscan.ImportMode // optional — empty means "use library.import_mode default" (only meaningful when Mode == rename)
}

StartScanParams is the input for Service.StartScan.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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