Documentation
¶
Index ¶
- Constants
- Variables
- type ARRsRepairService
- type ActiveStream
- type CorruptedFileError
- type MetadataFileInfo
- type MetadataRemoteFile
- func (mrf *MetadataRemoteFile) Mkdir(ctx context.Context, name string, perm os.FileMode) error
- func (mrf *MetadataRemoteFile) MkdirAll(ctx context.Context, name string, perm os.FileMode) error
- func (mrf *MetadataRemoteFile) OpenFile(ctx context.Context, name string) (bool, afero.File, error)
- func (mrf *MetadataRemoteFile) RemoveFile(ctx context.Context, fileName string) (bool, error)
- func (mrf *MetadataRemoteFile) RenameFile(ctx context.Context, oldName, newName string) (bool, error)
- func (mrf *MetadataRemoteFile) Stat(ctx context.Context, name string) (bool, fs.FileInfo, error)
- type MetadataSegmentLoader
- type MetadataVirtualDirectory
- func (mvd *MetadataVirtualDirectory) Close() error
- func (mvd *MetadataVirtualDirectory) Name() string
- func (mvd *MetadataVirtualDirectory) Read(p []byte) (n int, err error)
- func (mvd *MetadataVirtualDirectory) ReadAt(p []byte, off int64) (n int, err error)
- func (mvd *MetadataVirtualDirectory) Readdir(count int) ([]fs.FileInfo, error)
- func (mvd *MetadataVirtualDirectory) Readdirnames(n int) ([]string, error)
- func (mvd *MetadataVirtualDirectory) Seek(offset int64, whence int) (int64, error)
- func (mvd *MetadataVirtualDirectory) Stat() (fs.FileInfo, error)
- func (mvd *MetadataVirtualDirectory) Sync() error
- func (mvd *MetadataVirtualDirectory) Truncate(size int64) error
- func (mvd *MetadataVirtualDirectory) Write(p []byte) (n int, err error)
- func (mvd *MetadataVirtualDirectory) WriteAt(p []byte, off int64) (n int, err error)
- func (mvd *MetadataVirtualDirectory) WriteString(s string) (ret int, err error)
- type MetadataVirtualFile
- func (mvf *MetadataVirtualFile) Close() error
- func (mvf *MetadataVirtualFile) GetStreamID() string
- func (mvf *MetadataVirtualFile) Name() string
- func (mvf *MetadataVirtualFile) Read(p []byte) (n int, err error)
- func (mvf *MetadataVirtualFile) ReadAt(p []byte, off int64) (n int, err error)
- func (mvf *MetadataVirtualFile) ReadAtContext(readCtx context.Context, p []byte, off int64) (n int, err error)
- func (mvf *MetadataVirtualFile) Readdir(count int) ([]fs.FileInfo, error)
- func (mvf *MetadataVirtualFile) Readdirnames(n int) ([]string, error)
- func (mvf *MetadataVirtualFile) Seek(offset int64, whence int) (int64, error)
- func (mvf *MetadataVirtualFile) Stat() (fs.FileInfo, error)
- func (mvf *MetadataVirtualFile) Sync() error
- func (mvf *MetadataVirtualFile) Truncate(size int64) error
- func (mvf *MetadataVirtualFile) Write(p []byte) (n int, err error)
- func (mvf *MetadataVirtualFile) WriteAt(p []byte, off int64) (n int, err error)
- func (mvf *MetadataVirtualFile) WriteString(s string) (ret int, err error)
- type NzbFilesystem
- func (nfs *NzbFilesystem) Mkdir(ctx context.Context, name string, perm os.FileMode) error
- func (nfs *NzbFilesystem) MkdirAll(ctx context.Context, name string, perm os.FileMode) error
- func (nfs *NzbFilesystem) Name() string
- func (nfs *NzbFilesystem) Open(ctx context.Context, name string) (afero.File, error)
- func (nfs *NzbFilesystem) OpenFile(ctx context.Context, name string, flag int, perm os.FileMode) (afero.File, error)
- func (nfs *NzbFilesystem) Remove(ctx context.Context, name string) error
- func (nfs *NzbFilesystem) RemoveAll(ctx context.Context, name string) error
- func (nfs *NzbFilesystem) Rename(ctx context.Context, oldName, newName string) error
- func (nfs *NzbFilesystem) Stat(ctx context.Context, name string) (fs.FileInfo, error)
- type PartialContentError
- type RepairCoalescer
- type StreamTracker
Constants ¶
const ( ErrMsgFailedCreateDecryptReader = "failed to create decrypt reader: %w" ErrMsgFailedWrapEncryption = "failed to wrap reader with encryption: %w" )
Database operation error message templates
const (
// RootPath represents the root directory path
RootPath = "/"
)
File system constants
Variables ¶
var ( ErrInvalidWhence = errors.New("seek: invalid whence") ErrSeekNegative = errors.New("seek: negative position") ErrSeekTooFar = errors.New("seek: too far") )
Error constants
var ( ErrCannotRemoveRoot = errors.New("cannot remove root directory") ErrNotDirectory = errors.New("not a directory") ErrCannotReadDirectory = errors.New("cannot read from directory") ErrNegativeOffset = errors.New("negative offset") 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") ErrFileIsCorrupted = errors.New("file is corrupted, there are some missing segments") ErrFileClosed = errors.New("file closed") )
Error message constants
Functions ¶
This section is empty.
Types ¶
type ARRsRepairService ¶
type ARRsRepairService interface {
TriggerFileRescan(ctx context.Context, pathForRescan string, relativePath string, metadataStr *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 ¶
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, cacheSource *segcache.Source, ) *MetadataRemoteFile
NewMetadataRemoteFile creates a new metadata-based remote file handler
func (*MetadataRemoteFile) RemoveFile ¶
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
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. It delegates to ReadAtContext using the file-level context.
func (*MetadataVirtualFile) ReadAtContext ¶ added in v0.3.0
func (mvf *MetadataVirtualFile) ReadAtContext(readCtx context.Context, p []byte, off int64) (n int, err error)
ReadAtContext serves offset-based reads. Sequential offsets reuse the shared streaming reader (preserving the prefetch pipeline); non-sequential offsets use a short-lived range reader so the shared pipeline is not disturbed. All calls are serialized via mvf.mu — the caller (FUSE handle) must ensure per-handle ordering.
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) 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) MkdirAll ¶
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) 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
type PartialContentError ¶
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 RepairCoalescer ¶ added in v0.3.0
type RepairCoalescer struct {
// contains filtered or unexported fields
}
RepairCoalescer throttles per-file streaming-failure repair triggers and coalesces rclone VFS refresh calls so that a batch of corrupted reads cannot fan out into one RC POST per file.
Two mechanisms:
Per-path debounce — ShouldTrigger returns false if the same file path was triggered within the debounce window. This prevents repeated reads of the same corrupted file from re-firing the repair pipeline.
Directory-level VFS refresh coalescing — EnqueueRefresh adds a virtual directory to a pending set; a single worker goroutine drains the set, deduplicates, and issues at most one RefreshDir RC call at a time with a minimum interval between calls.
func NewRepairCoalescer ¶ added in v0.3.0
func NewRepairCoalescer(rclone rclonecli.RcloneRcClient, configGetter config.ConfigGetter) *RepairCoalescer
NewRepairCoalescer constructs a coalescer and starts its background worker. The worker runs for the lifetime of the process; call Close to stop it in tests or during graceful shutdown.
func (*RepairCoalescer) Close ¶ added in v0.3.0
func (c *RepairCoalescer) Close()
Close stops the background worker. Pending refreshes are dropped.
func (*RepairCoalescer) EnqueueRefresh ¶ added in v0.3.0
func (c *RepairCoalescer) EnqueueRefresh(virtualDir string)
EnqueueRefresh adds virtualDir to the set of directories that will be sent to rclone in the next batched vfs/refresh call. Duplicate directories within the same flush window collapse to a single entry.
func (*RepairCoalescer) ShouldTrigger ¶ added in v0.3.0
func (c *RepairCoalescer) ShouldTrigger(path string) bool
ShouldTrigger reports whether a streaming-failure repair should be fired for path. It returns true at most once per debounce window per path. Stale entries are pruned opportunistically on each call.
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