scanner

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package scanner provides directory scanning and NZBDav import functionality.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BatchQueueAdder

type BatchQueueAdder interface {
	AddBatchToQueue(ctx context.Context, items []*database.ImportQueueItem) error
}

BatchQueueAdder defines the interface for batch queue operations

type DirectoryScanner

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

DirectoryScanner handles manual directory scanning for NZB/STRM files

func NewDirectoryScanner

func NewDirectoryScanner(queueAdder QueueAdder) *DirectoryScanner

NewDirectoryScanner creates a new directory scanner

func (*DirectoryScanner) Cancel

func (d *DirectoryScanner) Cancel() error

Cancel cancels the current scan operation

func (*DirectoryScanner) GetStatus

func (d *DirectoryScanner) GetStatus() ScanInfo

GetStatus returns the current scan status

func (*DirectoryScanner) SetMaxScanDepth

func (d *DirectoryScanner) SetMaxScanDepth(depth int)

SetMaxScanDepth configures the maximum directory depth (0 = unlimited).

func (*DirectoryScanner) Start

func (d *DirectoryScanner) Start(scanPath string) error

Start starts a manual scan of the specified directory

type ImportInfo

type ImportInfo struct {
	Status    ImportJobStatus `json:"status"`
	Total     int             `json:"total"`
	Added     int             `json:"added"`
	Failed    int             `json:"failed"`
	Skipped   int             `json:"skipped"`
	LastError *string         `json:"last_error,omitempty"`
}

ImportInfo holds information about the current NZBDav import operation

type ImportJobStatus

type ImportJobStatus string

ImportJobStatus represents the status of an NZBDav import job

const (
	ImportStatusIdle      ImportJobStatus = "idle"
	ImportStatusRunning   ImportJobStatus = "running"
	ImportStatusCanceling ImportJobStatus = "canceling"
	ImportStatusCompleted ImportJobStatus = "completed"
)

type MigrationRecorder added in v0.3.0

type MigrationRecorder interface {
	UpsertMigration(ctx context.Context, source, externalID, relativePath string) (int64, error)
	IsMigrationCompleted(ctx context.Context, source, externalID string) (bool, error)
	// LinkQueueItemID sets queue_item_id for all migration rows identified by
	// (source, externalIDs) where queue_item_id is currently NULL. Called after
	// AddBatchToQueue assigns IDs to the queue items.
	LinkQueueItemID(ctx context.Context, source string, externalIDs []string, queueItemID int64) error
}

MigrationRecorder defines the interface for recording import migrations

type NzbDavImporter

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

NzbDavImporter handles importing from NZBDav databases

func NewNzbDavImporter

func NewNzbDavImporter(batchAdder BatchQueueAdder, migrationRecorder MigrationRecorder) *NzbDavImporter

NewNzbDavImporter creates a new NZBDav importer

func (*NzbDavImporter) Cancel

func (n *NzbDavImporter) Cancel() error

Cancel requests cancellation of the current import operation. Idempotent: calling while already canceling or idle is a no-op.

func (*NzbDavImporter) GetStatus

func (n *NzbDavImporter) GetStatus() ImportInfo

GetStatus returns the current import status

func (*NzbDavImporter) Reset

func (n *NzbDavImporter) Reset()

Reset force-clears the import state to Idle regardless of current status. If a goroutine is still running it receives a cancellation and its deferred state update is invalidated via the epoch bump — the caller can immediately Start a new import without being blocked by a stuck "Canceling" state.

func (*NzbDavImporter) Start

func (n *NzbDavImporter) Start(dbPath string, blobsPath string, cleanupFile bool) error

Start starts an asynchronous import from an NZBDav database

type QueueAdder

type QueueAdder interface {
	AddToQueue(ctx context.Context, filePath string, relativePath *string, metadata *string) error
	IsFileInQueue(ctx context.Context, filePath string) bool
	IsFileProcessed(filePath string, scanRoot string) bool
}

QueueAdder defines the interface for adding items to the queue

type ScanInfo

type ScanInfo struct {
	Status      ScanStatus `json:"status"`
	Path        string     `json:"path,omitempty"`
	StartTime   *time.Time `json:"start_time,omitempty"`
	FilesFound  int        `json:"files_found"`
	FilesAdded  int        `json:"files_added"`
	CurrentFile string     `json:"current_file,omitempty"`
	LastError   *string    `json:"last_error,omitempty"`
}

ScanInfo holds information about the current scan operation

type ScanStatus

type ScanStatus string

ScanStatus represents the current status of a manual scan

const (
	ScanStatusIdle      ScanStatus = "idle"
	ScanStatusScanning  ScanStatus = "scanning"
	ScanStatusCanceling ScanStatus = "canceling"
)

type WatchQueueAdder

type WatchQueueAdder interface {
	AddToQueue(ctx context.Context, filePath string, relativePath *string, category *string, priority *database.QueuePriority, metadata *string, downloadID *string, indexer *string) (*database.ImportQueueItem, error)
	IsFileInQueue(ctx context.Context, filePath string) (bool, error)
}

WatchQueueAdder interface for adding items to the import queue from directory watcher

type Watcher

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

Watcher handles monitoring a directory for new NZB files

func NewWatcher

func NewWatcher(queueAdder WatchQueueAdder, configGetter config.ConfigGetter) *Watcher

NewWatcher creates a new directory watcher

func (*Watcher) Start

func (w *Watcher) Start(ctx context.Context) error

Start starts the watcher loop

func (*Watcher) Stop

func (w *Watcher) Stop()

Stop stops the watcher

Jump to

Keyboard shortcuts

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