remotepath

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2026 License: MIT Imports: 9 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package remotepath implements remote path mappings, as in Sonarr. A download client that runs in a container or on another machine reports paths as it sees them (/downloads/Show.S01E01); a mapping rewrites that prefix to the same folder as Pilot sees it (/mnt/media/downloads).

Remote paths may be Unix or Windows style (a client on Windows reports C:\Downloads\...). They are compared by path component, with either separator, and case-insensitively for Windows paths.

Index

Constants

This section is empty.

Variables

View Source
var ErrNotFound = errors.New("remote path mapping not found")

ErrNotFound is returned when a mapping ID doesn't exist.

Functions

func Apply

func Apply(mappings []Mapping, clientID, path string) string

Apply rewrites path with the best matching mapping: the longest remote path that is path itself or a parent folder of it, preferring one for this client over one for any client. With no match, path is returned unchanged.

Types

type Mapping

type Mapping struct {
	ID               string
	DownloadClientID string // "" = any client
	RemotePath       string
	LocalPath        string
}

Mapping is one remote path mapping.

type Request

type Request struct {
	DownloadClientID string
	RemotePath       string
	LocalPath        string
}

Request is the editable part of a mapping.

type Service

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

Service stores mappings and applies them.

func NewService

func NewService(q db.Querier) *Service

NewService creates a Service.

func (*Service) Create

func (s *Service) Create(ctx context.Context, req Request) (Mapping, error)

Create validates and stores a mapping.

func (*Service) Delete

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

Delete removes a mapping.

func (*Service) List

func (s *Service) List(ctx context.Context) ([]Mapping, error)

List returns every mapping.

func (*Service) Map

func (s *Service) Map(ctx context.Context, clientID, path string) string

Map rewrites a path reported by the download client clientID. If the mappings can't be loaded, the path is returned unchanged.

func (*Service) Update

func (s *Service) Update(ctx context.Context, id string, req Request) (Mapping, error)

Update validates and replaces a mapping.

type ValidationError

type ValidationError struct{ Msg string }

ValidationError explains why a Request was rejected.

func (*ValidationError) Error

func (e *ValidationError) Error() string

Jump to

Keyboard shortcuts

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