domain

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CalculateFileHash added in v0.5.0

func CalculateFileHash(r io.Reader) (string, error)

CalculateFileHash generates the SHA-256 fingerprint for the actual NZB bytes. This is used for content-based deduplication and manual upload IDs.

func GenerateCompositeID added in v0.5.0

func GenerateCompositeID(source, guid string) string

GenerateCompositeID creates the SHA-256 PK for Indexer results. This ensure all IDs in the database are a consistent 64-character hex string.

Types

type DownloadFile

type DownloadFile struct {
	// Persistent fields (saved in release_files table)
	ID        int64
	ReleaseID string
	FileName  string // Sanitized filename
	Size      int64  // Expected total size from NZB
	Index     int    // Original order in the NZB
	IsPars    bool   // True if the file is a repar volume
	Subject   string
	Date      int64
	Groups    []string
	Poster    string

	// App State (calulated at hydration)
	PartPath   string
	FinalPath  string
	IsComplete bool
	Password   string

	Segments []Segment
	// contains filtered or unexported fields
}

DownloadFile represents an individual file within a Release.

func NewDownloadFile

func NewDownloadFile(fileName string, size int64, index int, segments []Segment, outDir string, password string) *DownloadFile

NewDownloadFile is the constructor for creating a live download task. If size is 0, it calculates the total size from the segment list.

func (*DownloadFile) GetActualSize

func (f *DownloadFile) GetActualSize() int64

func (*DownloadFile) Prepare added in v0.5.0

func (f *DownloadFile) Prepare(outDir string)

func (*DownloadFile) SetActualSize

func (f *DownloadFile) SetActualSize(size int64)

type JobStatus added in v0.5.0

type JobStatus string
const (
	StatusPending     JobStatus = "pending"
	StatusDownloading JobStatus = "downloading"
	StatusProcessing  JobStatus = "processing" // Post-processing (unrar/7z)
	StatusCompleted   JobStatus = "completed"
	StatusFailed      JobStatus = "failed"
)

type PreparationResult added in v0.5.0

type PreparationResult struct {
	Tasks     []*DownloadFile
	TotalSize int64
	Password  string
}

type QueueItem added in v0.5.0

type QueueItem struct {
	ID        string   // Unique KSUID for this job
	ReleaseID string   // Reference to the shared Release
	Release   *Release // Populated via JOIN from store
	Status    JobStatus
	OutDir    string

	// Tasks are only present in RAM. When loaded from queue_items,
	// this is nil until hydrated from BLOB store.
	Tasks []*DownloadFile

	BytesWritten atomic.Int64

	StartedAt time.Time
	Error     *string

	CancelFunc context.CancelFunc
}

QueueItem represents the entire NZB download process

func (*QueueItem) AddBytes added in v0.5.0

func (q *QueueItem) AddBytes(n int64)

func (*QueueItem) GetBytes added in v0.5.0

func (q *QueueItem) GetBytes() int64

type Release added in v0.5.0

type Release struct {
	ID              string    `json:"id"`
	FileHash        string    `json:"hash"`
	Title           string    `json:"title"`
	Password        string    `json:"password"`
	GUID            string    `json:"guid"`
	Source          string    `json:"source"`
	DownloadURL     string    `json:"downloadUrl"`
	Size            int64     `json:"size"`
	PublishDate     time.Time `json:"publishDate"`
	Category        string    `json:"category"`
	RedirectAllowed bool
	Poster          string
}

Release represents the NZB itself, whether from an indexer or a file upload.

type Segment added in v0.5.0

type Segment struct {
	Number      int
	Bytes       int64
	MessageID   string
	MissingFrom map[string]bool
}

Segment represents an individual article to be fetched from Usenet

Jump to

Keyboard shortcuts

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