rclone

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2022 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	JobInfoChan chan JobInfo
)

Functions

func CacheConfigProviders

func CacheConfigProviders() error

CacheConfigProviders fetches the provider list and stores it.

func CancelClientContext

func CancelClientContext()

CancelClientContext cancels the client context.

func DeleteConfig

func DeleteConfig(name string) error

DeleteConfig deletes the configuration.

func DialServer

func DialServer() error

DialServer checks whether the host is reachable.

func GetClientContext

func GetClientContext() context.Context

GetClientContext returns the client context.

func GetConfigSettings

func GetConfigSettings() (map[string]map[string]interface{}, error)

GetConfigSettings returns the list of configured remotes.

func GetCurrentSettings

func GetCurrentSettings() map[string]map[string]interface{}

GetCurrentSettings returns the cached list of remotes.

func GetJobQueue

func GetJobQueue() *sync.Map

GetJobQueue returns the job queue.

func GetNewJobID

func GetNewJobID(jobType string) int64

GetNewJobID generates a new job ID.

func GetProviderDesc

func GetProviderDesc(confType string) string

GetProviderDesc returns the providers description.

func GetSessions

func GetSessions() []string

GetSessions gets the running sessions.

func JobInfoStatus

func JobInfoStatus() chan JobInfo

JobInfoStatus returns the job stats update channel.

func Login

func Login(host, user, pass string) (string, error)

Login connects to the provided host with the username and password.

func MonitorJob

func MonitorJob(job *Job, nostop ...struct{})

MonitorJob monitors the provided job, and if nostop is not set, it will automatically stop monitoring the job.

func PollConnection

func PollConnection(updateMonitor bool) chan bool

PollConnection polls the connectivity status of the host.

func SaveConfig

func SaveConfig(data map[string]interface{}, create, interactiveConfig bool) error

SaveConfig saves the configuration.

func SetSession

func SetSession(host string)

SetSession sets the current session.

func SetupClient

func SetupClient(host, user, pass string) error

SetupClient sets up the client.

func StartDashboard

func StartDashboard() (chan DashboardInfo, chan struct{})

StartDashboard starts polling for rclone stats.

func StopDashboard

func StopDashboard()

StopDashboard stops polling for rclone stats.

func StopJob

func StopJob(job *Job, errors string, force ...struct{})

StopJob stops the provided job.

func StopJobGroup

func StopJobGroup(job *Job)

StopJobGroup stops all jobs associated with the group.

Types

type Client

type Client struct {
	Host string
	URI  *url.URL
	// contains filtered or unexported fields
}

Client stores host/client information and its credentials.

func GetClient

func GetClient(host string, nolock ...struct{}) (*Client, error)

GetClient gets the client which corresponds to the provided host.

func GetCurrentClient

func GetCurrentClient() (*Client, error)

GetCurrentClient gets the client associated with the current host.

func (*Client) Hostname

func (c *Client) Hostname() string

Hostname returns the client's hostname.

func (*Client) SendRequest

func (c *Client) SendRequest(command map[string]interface{}, endpoint string, ctx ...context.Context) (Response, error)

SendRequest sends a request to the rclone host and returns a response.

type ConfigProviders

type ConfigProviders struct {
	Providers []Provider `json:"providers"`
}

ConfigProviders stores the list of configuration providers.

func GetConfigProviders

func GetConfigProviders() (ConfigProviders, error)

GetConfigProviders returns the list of providers.

type DashboardInfo

type DashboardInfo struct {
	Connected bool
	Bandwidth string
	Stats     *DashboardStats

	User    string
	Version string
}

DashboardInfo stores the dashboard information.

type DashboardStats

type DashboardStats struct {
	Bytes          int64          `json:"bytes"`
	Checks         int64          `json:"checks"`
	DeletedDirs    int64          `json:"deletedDirs"`
	Deletes        int64          `json:"deletes"`
	ElapsedTime    float64        `json:"elapsedTime"`
	Errors         int64          `json:"errors"`
	Eta            int64          `json:"eta"`
	FatalError     bool           `json:"fatalError"`
	Renames        int64          `json:"renames"`
	RetryError     bool           `json:"retryError"`
	Speed          float64        `json:"speed"`
	TotalBytes     int64          `json:"totalBytes"`
	TotalChecks    int64          `json:"totalChecks"`
	TotalTransfers int64          `json:"totalTransfers"`
	TransferTime   int64          `json:"transferTime"`
	Transferring   []TransferStat `json:"transferring"`
	Transfers      int64          `json:"transfers"`
}

DashboardStats stores the rclone stats.

type Job

type Job struct {
	ID      int64
	Group   string
	Context context.Context

	Type        string
	Description string
	Updates     chan JobInfo
	Cancel      context.CancelFunc

	RefreshItems interface{}
}

Job stores the rclone job information.

func AddJobToQueue

func AddJobToQueue(job *Job, nomonitor ...struct{}) *Job

AddJobToQueue adds a job to the queue and if nomonitor is not set, will automatically start to monitor the job.

func GetLatestJob

func GetLatestJob(jobType string) (*Job, error)

GetLatestJob gets the latest job associated with the provided job type.

func NewJob

func NewJob(jobType, jobDesc string, jobId int64, jobGroup ...string) *Job

NewJob returns a job with the provided type, description, and optional group.

func SendCommandAsync

func SendCommandAsync(
	jobType, jobDesc string,
	command map[string]interface{}, endpoint string,
	noqueue ...struct{},
) (*Job, error)

SendCommandAsync asynchronously sends a command to rclone and returns the job information for the running command.

type JobInfo

type JobInfo struct {
	Duration  float64                `json:"duration"`
	EndTime   time.Time              `json:"endTime"`
	Error     string                 `json:"error"`
	Finished  bool                   `json:"finished"`
	Group     string                 `json:"group"`
	ID        int64                  `json:"id"`
	Output    map[string]interface{} `json:"output"`
	StartTime time.Time              `json:"startTime"`
	Success   bool                   `json:"success"`
	Transfers struct {
		Stats []TransferStat `json:"transferring"`
	}

	JobCount          int64
	Type, Description string
	CurrentTransfer   TransferStat

	RefreshItems interface{}
}

JobInfo stores the rclone running job stats.

func GetJobReply

func GetJobReply(job *Job) (JobInfo, error)

GetJobReply polls the job status and returns its output information when the job has finished.

type Provider

type Provider struct {
	Name        string           `json:"Name"`
	Description string           `json:"Description"`
	Prefix      string           `json:"Prefix"`
	Options     []ProviderOption `json:"Options"`
}

Provider stores the provider information.

func GetProviderByDesc

func GetProviderByDesc(confDesc string) (Provider, error)

GetProviderByDesc matches and returns a provider by its description.

func GetProviderByType

func GetProviderByType(confType string) (Provider, error)

GetProviderByType matches and returns a provider by its type.

type ProviderOption

type ProviderOption struct {
	Name       string `json:"Name"`
	Help       string `json:"Help"`
	Provider   string `json:"Provider"`
	ShortOpt   string `json:"ShortOpt"`
	Hide       int    `json:"Hide"`
	Required   bool   `json:"Required"`
	IsPassword bool   `json:"IsPassword"`
	NoPrefix   bool   `json:"NoPrefix"`
	Advanced   bool   `json:"Advanced"`
	Exclusive  bool   `json:"Exclusive"`
	DefaultStr string `json:"DefaultStr"`
	ValueStr   string `json:"ValueStr"`
	Type       string `json:"Type"`
	Examples   []struct {
		Value    string `json:"Value"`
		Help     string `json:"Help"`
		Provider string `json:"Provider"`
	} `json:"Examples"`
}

ProviderOption stores the provider's option data.

type Response

type Response struct {
	Body io.ReadCloser
}

Response stores the response obtained after a client request.

func SendCommand

func SendCommand(command map[string]interface{}, endpoint string, ctx ...context.Context) (Response, error)

SendCommand sends a command to the rclone host and returns a response. This is a blocking call.

func (*Response) Decode

func (r *Response) Decode(v interface{}) error

Decode unmarshals the json response into the provided data.

type TransferStat

type TransferStat struct {
	Name       string  `json:"name"`
	Size       int64   `json:"size"`
	Bytes      int64   `json:"bytes,omitempty"`
	Eta        int64   `json:"eta,omitempty"`
	Group      string  `json:"group,omitempty"`
	Percentage int64   `json:"percentage,omitempty"`
	Speed      float64 `json:"speed,omitempty"`
	SpeedAvg   float64 `json:"speedAvg,omitempty"`
}

TransferStat stores the file transfer stats.

type Version

type Version struct {
	Arch      string `json:"arch"`
	GoTags    string `json:"goTags"`
	GoVersion string `json:"goVersion"`
	IsBeta    bool   `json:"isBeta"`
	IsGit     bool   `json:"isGit"`
	Linking   string `json:"linking"`
	Os        string `json:"os"`
	Version   string `json:"version"`
}

func GetVersion

func GetVersion(force bool) (Version, error)

GetVersion returns the version.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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