rclonecli

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: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExitCode

func ExitCode(err error) (int, bool)

ExitCode returns the numeric exit code when available.

func TestConnection

func TestConnection(
	ctx context.Context,
	rcUrl string,
	rcUser string,
	rcPass string,
	vfsName string,
	httpClient *http.Client,
) error

func WasHardTerminated

func WasHardTerminated(err error) bool

WasHardTerminated reports true iff the process was ended by SIGKILL or SIGTERM.

Types

type BandwidthStats

type BandwidthStats struct {
	BytesPerSecond int64  `json:"bytesPerSecond"`
	Rate           string `json:"rate"`
}

type CoreStatsResponse

type CoreStatsResponse struct {
	Bytes          int64              `json:"bytes"`
	Checks         int                `json:"checks"`
	DeletedDirs    int                `json:"deletedDirs"`
	Deletes        int                `json:"deletes"`
	ElapsedTime    float64            `json:"elapsedTime"`
	Errors         int                `json:"errors"`
	Eta            int                `json:"eta"`
	Speed          float64            `json:"speed"`
	TotalBytes     int64              `json:"totalBytes"`
	TotalChecks    int                `json:"totalChecks"`
	TotalTransfers int                `json:"totalTransfers"`
	TransferTime   float64            `json:"transferTime"`
	Transfers      int                `json:"transfers"`
	Transferring   []TransferringStat `json:"transferring,omitempty"`
}

type Manager

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

Manager handles the rclone RC server and provides mount operations

func NewManager

func NewManager(cfm *config.Manager) *Manager

NewManager creates a new rclone RC manager

func (*Manager) GetAllMounts

func (m *Manager) GetAllMounts() map[string]*MountInfo

GetAllMounts returns information about all mounts

func (*Manager) GetBandwidthStats

func (m *Manager) GetBandwidthStats(ctx context.Context) (*BandwidthStats, error)

GetBandwidthStats returns bandwidth usage for all transfers

func (*Manager) GetCoreStats

func (m *Manager) GetCoreStats(ctx context.Context) (*CoreStatsResponse, error)

func (*Manager) GetLogger

func (m *Manager) GetLogger() *slog.Logger

func (*Manager) GetMemoryUsage

func (m *Manager) GetMemoryUsage(ctx context.Context) (*MemoryStats, error)

GetMemoryUsage returns memory usage statistics

func (*Manager) GetMountInfo

func (m *Manager) GetMountInfo(provider string) (*MountInfo, bool)

GetMountInfo returns information about a specific mount

func (*Manager) GetStats

func (m *Manager) GetStats(ctx context.Context) (*Stats, error)

GetStats retrieves statistics from the rclone RC server

func (*Manager) GetVersion

func (m *Manager) GetVersion(ctx context.Context) (*VersionResponse, error)

GetVersion returns rclone version information

func (*Manager) HealthCheck

func (m *Manager) HealthCheck(ctx context.Context) error

HealthCheck performs comprehensive health checks on the rclone system

func (*Manager) IsMounted

func (m *Manager) IsMounted(provider string) bool

IsMounted checks if a provider is mounted

func (*Manager) IsReady

func (m *Manager) IsReady() bool

IsReady returns true if the RC server is ready

func (*Manager) MonitorMounts

func (m *Manager) MonitorMounts(ctx context.Context)

MonitorMounts continuously monitors mount health and attempts recovery

func (*Manager) Mount

func (m *Manager) Mount(ctx context.Context, provider, mountPath, webdavURL string) error

Mount creates a mount using the rclone RC API with retry logic

func (*Manager) RecoverMount

func (m *Manager) RecoverMount(ctx context.Context, provider string) error

RecoverMount attempts to recover a failed mount

func (*Manager) RefreshDir

func (m *Manager) RefreshDir(ctx context.Context, provider string, dirs []string) error

RefreshDir refreshes directories in the VFS cache

func (*Manager) Start

func (m *Manager) Start(ctx context.Context) error

Start starts the rclone RC server

func (*Manager) Stop

func (m *Manager) Stop() error

Stop stops the rclone RC server and unmounts all mounts

func (*Manager) Unmount

func (m *Manager) Unmount(ctx context.Context, provider string) error

Unmount unmounts a specific provider

func (*Manager) UnmountAll

func (m *Manager) UnmountAll(ctx context.Context) error

UnmountAll unmounts all mounts

func (*Manager) WaitForReady

func (m *Manager) WaitForReady(timeout time.Duration) error

WaitForReady waits for the RC server to be ready

type MemoryStats

type MemoryStats struct {
	Sys        int   `json:"Sys"`
	TotalAlloc int64 `json:"TotalAlloc"`
}

type Mount

type Mount struct {
	Provider  string
	LocalPath string
	WebDAVURL string
	// contains filtered or unexported fields
}

Mount represents a mount using the rclone RC client

func NewMount

func NewMount(provider, mountPath, webdavURL string, rcManager *Manager) *Mount

NewMount creates a new RC-based mount

func (*Mount) GetMountInfo

func (m *Mount) GetMountInfo() (*MountInfo, bool)

GetMountInfo returns mount information

func (*Mount) IsMounted

func (m *Mount) IsMounted() bool

IsMounted checks if the mount is active via RC

func (*Mount) Mount

func (m *Mount) Mount(ctx context.Context) error

Mount creates the mount using rclone RC

func (*Mount) RefreshDir

func (m *Mount) RefreshDir(ctx context.Context, dirs []string) error

RefreshDir refreshes directories in the mount

func (*Mount) Unmount

func (m *Mount) Unmount(ctx context.Context) error

Unmount removes the mount using rclone RC

type MountInfo

type MountInfo struct {
	Provider   string `json:"provider"`
	LocalPath  string `json:"local_path"`
	WebDAVURL  string `json:"webdav_url"`
	Mounted    bool   `json:"mounted"`
	MountedAt  string `json:"mounted_at,omitempty"`
	ConfigName string `json:"config_name"`
	Error      string `json:"error,omitempty"`
}

type RCRequest

type RCRequest struct {
	Command string         `json:"command"`
	Args    map[string]any `json:"args,omitempty"`
}

type RCResponse

type RCResponse struct {
	Result any    `json:"result,omitempty"`
	Error  string `json:"error,omitempty"`
}

type RcloneRcClient

type RcloneRcClient interface {
	RefreshDir(ctx context.Context, provider string, dirs []string) error
}

func NewRcloneRcClient

func NewRcloneRcClient(
	config *config.Manager,
	httpClient *http.Client,
) RcloneRcClient

type Stats

type Stats struct {
	Enabled   bool                  `json:"enabled"`
	Ready     bool                  `json:"server_ready"`
	Core      CoreStatsResponse     `json:"core"`
	Memory    MemoryStats           `json:"memory"`
	Mount     map[string]*MountInfo `json:"mount"`
	Bandwidth BandwidthStats        `json:"bandwidth"`
	Version   VersionResponse       `json:"version"`
}

Stats represents rclone statistics

type TransferringStat

type TransferringStat struct {
	Bytes    int64   `json:"bytes"`
	ETA      int64   `json:"eta"`
	Name     string  `json:"name"`
	Speed    float64 `json:"speed"`
	Size     int64   `json:"size"`
	Progress float64 `json:"progress"`
}

type VersionResponse

type VersionResponse struct {
	Arch    string `json:"arch"`
	Version string `json:"version"`
	OS      string `json:"os"`
}

Jump to

Keyboard shortcuts

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