Documentation
¶
Overview ¶
Package downloads downloads chapters into the shared library: one file per chapter, stored once for everyone, as a CBZ with ComicInfo.xml, on the default storage. Downloads are tasks: de-duplicated across users, retried with back-off, and capped per source across all users.
Index ¶
- Constants
- Variables
- func Render(template string, p NameParts) string
- type File
- type Item
- type NameParts
- type Queued
- type Service
- func (s *Service) DeleteFile(ctx context.Context, chapterID uuid.UUID) error
- func (s *Service) Downloaded(ctx context.Context, workID uuid.UUID) (map[uuid.UUID]bool, error)
- func (s *Service) List(ctx context.Context, userID *uuid.UUID, state string, before *db.Task, ...) ([]Item, error)
- func (s *Service) Move(ctx context.Context, by uuid.UUID, from, to string) (db.Task, error)
- func (s *Service) NewChapters(ctx context.Context, workID uuid.UUID, chapterIDs []uuid.UUID)
- func (s *Service) Open(ctx context.Context, chapterID uuid.UUID) (*File, error)
- func (s *Service) Queue(ctx context.Context, by uuid.UUID, workID uuid.UUID, chapterIDs []uuid.UUID) (Queued, error)
- func (s *Service) SetAutoDownload(ctx context.Context, userID, workID uuid.UUID, on bool) error
Constants ¶
const ( KindDownload = "download.chapter" KindMove = "storage.move" )
Task kinds.
const DefaultTemplate = "{work} [{work_id}]/{volume} {chapter} - {title} [{group}].cbz"
DefaultTemplate names downloaded chapters: one folder per work (the ID keeps two works with the same title apart and survives renames).
Variables ¶
var ( ErrNotFound = errors.New("downloads: not found") ErrNotStored = errors.New("downloads: the chapter isn't downloaded") ErrSameTarget = errors.New("downloads: the files are on that storage already") )
Errors callers map to responses.
Functions ¶
Types ¶
type Item ¶
type Item struct {
Task db.Task
ChapterID uuid.UUID
WorkID uuid.UUID
WorkTitle string
ChapterNumber *float64
ChapterTitle string
}
Item is a download task with its chapter and work.
type NameParts ¶
type NameParts struct {
Work string
WorkID string
Volume string
Number *float64
Title string
Group string
Lang string
ExtraID string
}
NameParts are what a file name is made of.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service downloads chapters.
func NewService ¶
func NewService(st *store.Store, host *plugins.Host, storages *storage.Manager, m *meta.Service, q *queue.Queue, lim *limits.Registry, hub *events.Hub, tmpDir string, log *slog.Logger, ) *Service
NewService returns the service and registers its task kinds on q.
func (*Service) DeleteFile ¶
DeleteFile deletes a chapter's downloaded file (an admin's action).
func (*Service) Downloaded ¶
Downloaded returns which of a work's chapters have files.
func (*Service) List ¶
func (s *Service) List(ctx context.Context, userID *uuid.UUID, state string, before *db.Task, limit int) ([]Item, error)
List returns download tasks, newest first: all for admins, otherwise the ones userID asked for.
func (*Service) NewChapters ¶
NewChapters queues downloads of a work's new chapters for followers who asked for them and may download.