nzbfilesystem

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2026 License: MIT Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ErrMsgFailedQueryVirtualFile    = "failed to query virtual file: %w"
	ErrMsgFailedDeleteVirtualFile   = "failed to delete virtual file: %w"
	ErrMsgFailedCheckDestination    = "failed to check destination: %w"
	ErrMsgFailedFindParent          = "failed to find parent directory: %w"
	ErrMsgFailedMoveFile            = "failed to move file: %w"
	ErrMsgFailedUpdateFilename      = "failed to update filename: %w"
	ErrMsgFailedGetDescendants      = "failed to get descendants: %w"
	ErrMsgFailedUpdateDescPath      = "failed to update descendant path: %w"
	ErrMsgFailedListDirectory       = "failed to list directory contents: %w"
	ErrMsgFailedCreateUsenetReader  = "failed to create usenet reader: %w"
	ErrMsgFailedCreateDecryptReader = "failed to create decrypt reader: %w"
	ErrMsgFailedWrapEncryption      = "failed to wrap reader with encryption: %w"
)

Database operation error message templates

View Source
const (
	ErrMsgReadOutsideRange = "read offset %d is outside requested range %d-%d"
)

Range validation error message templates

View Source
const (
	// RootPath represents the root directory path
	RootPath = "/"
)

File system constants

Variables

View Source
var (
	ErrInvalidWhence = errors.New("seek: invalid whence")
	ErrSeekNegative  = errors.New("seek: negative position")
	ErrSeekTooFar    = errors.New("seek: too far")
)

Error constants

View Source
var (
	ErrCannotRemoveRoot     = errors.New("cannot remove root directory")
	ErrCannotRenameRoot     = errors.New("cannot rename root directory")
	ErrCannotRenameToRoot   = errors.New("cannot rename to root directory")
	ErrDestinationExists    = errors.New("destination already exists")
	ErrNotDirectory         = errors.New("not a directory")
	ErrCannotReadDirectory  = errors.New("cannot read from directory")
	ErrNegativeOffset       = errors.New("negative offset")
	ErrVirtualFileNotInit   = errors.New("virtual file not initialized")
	ErrMissmatchedSegments  = errors.New("missmatched segments for file size")
	ErrNoUsenetPool         = errors.New("usenet connection pool not configured")
	ErrNoCipherConfig       = errors.New("no cipher configured for encryption")
	ErrNoEncryptionParams   = errors.New("no NZB data available for encryption parameters")
	ErrTruncateNotSupported = errors.New("truncate not supported for virtual files")
	ErrWriteNotSupported    = errors.New("write not supported for virtual files")
	ErrFailedListDirectory  = errors.New("failed to list directory contents")
	ErrFileIsCorrupted      = errors.New("file is corrupted, there are some missing segments")
)

Error message constants

Functions

This section is empty.

Types

type ARRsRepairService

type ARRsRepairService interface {
	TriggerFileRescan(ctx context.Context, pathForRescan string, relativePath string) error
}

ARRsRepairService abstracts the ARR repair operations needed by the filesystem.

type ActiveStream

type ActiveStream struct {
	ID               string    `json:"id"`
	FilePath         string    `json:"file_path"`
	StartedAt        time.Time `json:"started_at"`
	LastActivity     time.Time `json:"last_activity"`
	Source           string    `json:"source"`
	UserName         string    `json:"user_name,omitempty"`
	ClientIP         string    `json:"client_ip,omitempty"`
	UserAgent        string    `json:"user_agent,omitempty"`
	TotalSize        int64     `json:"total_size"`
	BytesSent        int64     `json:"bytes_sent"`
	BytesDownloaded  int64     `json:"bytes_downloaded"`
	CurrentOffset    int64     `json:"current_offset"`
	BytesPerSecond   int64     `json:"bytes_per_second"`
	DownloadSpeed    int64     `json:"download_speed"`
	SpeedAvg         int64     `json:"speed_avg"`
	ETA              int64     `json:"eta"` // Seconds remaining
	TotalConnections int       `json:"total_connections"`
	BufferedOffset   int64     `json:"buffered_offset"`
	Status           string    `json:"status"` // e.g., "Buffering", "Streaming", "Stalled"
}

ActiveStream represents a file currently being streamed

type CorruptedFileError

type CorruptedFileError struct {
	TotalExpected int64
	UnderlyingErr error
}

CorruptedFileError represents an error where no articles could be read (complete failure)

func (*CorruptedFileError) Error

func (e *CorruptedFileError) Error() string

func (*CorruptedFileError) Unwrap

func (e *CorruptedFileError) Unwrap() error

type MetadataFileInfo

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

MetadataFileInfo implements fs.FileInfo for metadata-based files

func (*MetadataFileInfo) IsDir

func (mfi *MetadataFileInfo) IsDir() bool

func (*MetadataFileInfo) ModTime

func (mfi *MetadataFileInfo) ModTime() time.Time

func (*MetadataFileInfo) Mode

func (mfi *MetadataFileInfo) Mode() os.FileMode

func (*MetadataFileInfo) Name

func (mfi *MetadataFileInfo) Name() string

func (*MetadataFileInfo) Size

func (mfi *MetadataFileInfo) Size() int64

func (*MetadataFileInfo) Sys

func (mfi *MetadataFileInfo) Sys() any

type MetadataRemoteFile

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

MetadataRemoteFile implements the RemoteFile interface for metadata-backed virtual files

func NewMetadataRemoteFile

func NewMetadataRemoteFile(
	metadataService *metadata.MetadataService,
	healthRepository *database.HealthRepository,
	arrsService ARRsRepairService,
	rcloneClient rclonecli.RcloneRcClient,
	poolManager pool.Manager,
	configGetter config.ConfigGetter,
	streamTracker StreamTracker,
	segmentStore usenet.SegmentStore,
) *MetadataRemoteFile

NewMetadataRemoteFile creates a new metadata-based remote file handler

func (*MetadataRemoteFile) Mkdir

func (mrf *MetadataRemoteFile) Mkdir(ctx context.Context, name string, perm os.FileMode) error

func (*MetadataRemoteFile) MkdirAll

func (mrf *MetadataRemoteFile) MkdirAll(ctx context.Context, name string, perm os.FileMode) error

func (*MetadataRemoteFile) OpenFile

func (mrf *MetadataRemoteFile) OpenFile(ctx context.Context, name string) (bool, afero.File, error)

OpenFile opens a virtual file backed by metadata

func (*MetadataRemoteFile) RemoveFile

func (mrf *MetadataRemoteFile) RemoveFile(ctx context.Context, fileName string) (bool, error)

RemoveFile removes a virtual file or directory from the metadata

func (*MetadataRemoteFile) RenameFile

func (mrf *MetadataRemoteFile) RenameFile(ctx context.Context, oldName, newName string) (bool, error)

RenameFile renames a virtual file or directory in the metadata

func (*MetadataRemoteFile) Stat

func (mrf *MetadataRemoteFile) Stat(ctx context.Context, name string) (bool, fs.FileInfo, error)

Stat returns file information for a path using metadata

type MetadataSegmentLoader

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

MetadataSegmentLoader adapts metadata segments to the usenet.SegmentLoader interface

func (*MetadataSegmentLoader) GetSegment

func (msl *MetadataSegmentLoader) GetSegment(index int) (segment usenet.Segment, groups []string, ok bool)

GetSegment implements usenet.SegmentLoader interface

type MetadataVirtualDirectory

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

MetadataVirtualDirectory implements afero.File for metadata-backed virtual directories

func (*MetadataVirtualDirectory) Close

func (mvd *MetadataVirtualDirectory) Close() error

Close implements afero.File.Close

func (*MetadataVirtualDirectory) Name

func (mvd *MetadataVirtualDirectory) Name() string

Name implements afero.File.Name

func (*MetadataVirtualDirectory) Read

func (mvd *MetadataVirtualDirectory) Read(p []byte) (n int, err error)

Read implements afero.File.Read (not supported for directories)

func (*MetadataVirtualDirectory) ReadAt

func (mvd *MetadataVirtualDirectory) ReadAt(p []byte, off int64) (n int, err error)

ReadAt implements afero.File.ReadAt (not supported for directories)

func (*MetadataVirtualDirectory) Readdir

func (mvd *MetadataVirtualDirectory) Readdir(count int) ([]fs.FileInfo, error)

Readdir implements afero.File.Readdir

func (*MetadataVirtualDirectory) Readdirnames

func (mvd *MetadataVirtualDirectory) Readdirnames(n int) ([]string, error)

Readdirnames implements afero.File.Readdirnames

func (*MetadataVirtualDirectory) Seek

func (mvd *MetadataVirtualDirectory) Seek(offset int64, whence int) (int64, error)

Seek implements afero.File.Seek (not supported for directories)

func (*MetadataVirtualDirectory) Stat

func (mvd *MetadataVirtualDirectory) Stat() (fs.FileInfo, error)

Stat implements afero.File.Stat

func (*MetadataVirtualDirectory) Sync

func (mvd *MetadataVirtualDirectory) Sync() error

Sync implements afero.File.Sync (no-op for directories)

func (*MetadataVirtualDirectory) Truncate

func (mvd *MetadataVirtualDirectory) Truncate(size int64) error

Truncate implements afero.File.Truncate (not supported)

func (*MetadataVirtualDirectory) Write

func (mvd *MetadataVirtualDirectory) Write(p []byte) (n int, err error)

Write implements afero.File.Write (not supported)

func (*MetadataVirtualDirectory) WriteAt

func (mvd *MetadataVirtualDirectory) WriteAt(p []byte, off int64) (n int, err error)

WriteAt implements afero.File.WriteAt (not supported)

func (*MetadataVirtualDirectory) WriteString

func (mvd *MetadataVirtualDirectory) WriteString(s string) (ret int, err error)

WriteString implements afero.File.WriteString (not supported)

type MetadataVirtualFile

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

MetadataVirtualFile implements afero.File for metadata-backed virtual files

func (*MetadataVirtualFile) Close

func (mvf *MetadataVirtualFile) Close() error

Close implements afero.File.Close

func (*MetadataVirtualFile) GetStreamID

func (mvf *MetadataVirtualFile) GetStreamID() string

GetStreamID returns the active stream ID associated with this file handle

func (*MetadataVirtualFile) Name

func (mvf *MetadataVirtualFile) Name() string

Name implements afero.File.Name

func (*MetadataVirtualFile) Read

func (mvf *MetadataVirtualFile) Read(p []byte) (n int, err error)

Read implements afero.File.Read

func (*MetadataVirtualFile) ReadAt

func (mvf *MetadataVirtualFile) ReadAt(p []byte, off int64) (n int, err error)

ReadAt implements afero.File.ReadAt with concurrent random access support. Unlike Read(), this method creates an independent reader for each call, allowing concurrent reads at different offsets without mutex serialization.

func (*MetadataVirtualFile) Readdir

func (mvf *MetadataVirtualFile) Readdir(count int) ([]fs.FileInfo, error)

Readdir implements afero.File.Readdir

func (*MetadataVirtualFile) Readdirnames

func (mvf *MetadataVirtualFile) Readdirnames(n int) ([]string, error)

Readdirnames implements afero.File.Readdirnames

func (*MetadataVirtualFile) Seek

func (mvf *MetadataVirtualFile) Seek(offset int64, whence int) (int64, error)

Seek implements afero.File.Seek

func (*MetadataVirtualFile) Stat

func (mvf *MetadataVirtualFile) Stat() (fs.FileInfo, error)

Stat implements afero.File.Stat

func (*MetadataVirtualFile) Sync

func (mvf *MetadataVirtualFile) Sync() error

Sync implements afero.File.Sync (no-op for read-only)

func (*MetadataVirtualFile) Truncate

func (mvf *MetadataVirtualFile) Truncate(size int64) error

Truncate implements afero.File.Truncate (not supported)

func (*MetadataVirtualFile) WarmUp

func (mvf *MetadataVirtualFile) WarmUp()

WarmUp triggers a background pre-fetch of the file start

func (*MetadataVirtualFile) Write

func (mvf *MetadataVirtualFile) Write(p []byte) (n int, err error)

Write implements afero.File.Write (not supported)

func (*MetadataVirtualFile) WriteAt

func (mvf *MetadataVirtualFile) WriteAt(p []byte, off int64) (n int, err error)

WriteAt implements afero.File.WriteAt (not supported)

func (*MetadataVirtualFile) WriteString

func (mvf *MetadataVirtualFile) WriteString(s string) (ret int, err error)

WriteString implements afero.File.WriteString (not supported)

type NzbFilesystem

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

NzbFilesystem implements afero.Fs interface directly using the metadata service

func NewNzbFilesystem

func NewNzbFilesystem(remoteFile *MetadataRemoteFile) *NzbFilesystem

NewNzbFilesystem creates a new filesystem backed directly by metadata

func (*NzbFilesystem) Chmod

func (nfs *NzbFilesystem) Chmod(name string, mode os.FileMode) error

Chmod changes file permissions (not supported)

func (*NzbFilesystem) Chown

func (nfs *NzbFilesystem) Chown(name string, uid, gid int) error

Chown changes file ownership (not supported)

func (*NzbFilesystem) Chtimes

func (nfs *NzbFilesystem) Chtimes(name string, atime, mtime time.Time) error

Chtimes changes file times (not supported)

func (*NzbFilesystem) Create

func (nfs *NzbFilesystem) Create(name string) (afero.File, error)

Create creates a new file (not supported - read-only filesystem)

func (*NzbFilesystem) GetRemoteFile

func (nfs *NzbFilesystem) GetRemoteFile() *MetadataRemoteFile

GetRemoteFile returns the underlying MetadataRemoteFile for configuration updates

func (*NzbFilesystem) Mkdir

func (nfs *NzbFilesystem) Mkdir(ctx context.Context, name string, perm os.FileMode) error

Mkdir creates a directory (not supported - read-only filesystem)

func (*NzbFilesystem) MkdirAll

func (nfs *NzbFilesystem) MkdirAll(ctx context.Context, name string, perm os.FileMode) error

MkdirAll creates a directory and all parent directories (not supported)

func (*NzbFilesystem) Name

func (nfs *NzbFilesystem) Name() string

Name returns the filesystem name

func (*NzbFilesystem) Open

func (nfs *NzbFilesystem) Open(ctx context.Context, name string) (afero.File, error)

Open opens a file for reading

func (*NzbFilesystem) OpenFile

func (nfs *NzbFilesystem) OpenFile(ctx context.Context, name string, flag int, perm os.FileMode) (afero.File, error)

OpenFile opens a file with specified flags and permissions

func (*NzbFilesystem) Remove

func (nfs *NzbFilesystem) Remove(ctx context.Context, name string) error

Remove removes a file (not supported)

func (*NzbFilesystem) RemoveAll

func (nfs *NzbFilesystem) RemoveAll(ctx context.Context, name string) error

RemoveAll removes a file and any children

func (*NzbFilesystem) Rename

func (nfs *NzbFilesystem) Rename(ctx context.Context, oldName, newName string) error

Rename renames a file (not supported)

func (*NzbFilesystem) Stat

func (nfs *NzbFilesystem) Stat(ctx context.Context, name string) (fs.FileInfo, error)

Stat returns file information

type PartialContentError

type PartialContentError struct {
	BytesRead     int64
	TotalExpected int64
	UnderlyingErr error
}

PartialContentError represents an error where some articles are missing but some content was read

func (*PartialContentError) Error

func (e *PartialContentError) Error() string

func (*PartialContentError) Unwrap

func (e *PartialContentError) Unwrap() error

type StreamTracker

type StreamTracker interface {
	Add(filePath, source, userName, clientIP, userAgent string, totalSize int64) string
	UpdateProgress(id string, bytesRead int64)
	UpdateDownloadProgress(id string, bytesDownloaded int64)
	UpdateCurrentOffset(id string, offset int64)
	UpdateBufferedOffset(id string, offset int64)
	Remove(id string)
	IncArticlesDownloaded()
	IncArticlesPosted()
}

StreamTracker interface for tracking active streams

Directories

Path Synopsis
Package segcache provides a segment-aligned disk cache for Usenet file data.
Package segcache provides a segment-aligned disk cache for Usenet file data.

Jump to

Keyboard shortcuts

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