fs

package
v0.0.0-...-bc25190 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2017 License: MIT Imports: 48 Imported by: 0

Documentation

Overview

Package fs is a generic file system interface for rclone object storage systems

Index

Constants

View Source
const (

	// ConfigToken is the key used to store the token under
	ConfigToken = "token"

	// ConfigClientID is the config key used to store the client id
	ConfigClientID = "client_id"

	// ConfigClientSecret is the config key used to store the client secret
	ConfigClientSecret = "client_secret"

	// ConfigAutomatic indicates that we want non-interactive configuration
	ConfigAutomatic = "config_automatic"
)
View Source
const (
	// ModTimeNotSupported is a very large precision value to show
	// mod time isn't supported on this Fs
	ModTimeNotSupported = 100 * 365 * 24 * time.Hour
	// MaxLevel is a sentinel representing an infinite depth for listings
	MaxLevel = math.MaxInt32
)

Constants

Variables

View Source
var (

	// ConfigPath points to the config file
	ConfigPath = makeConfigPath()
	// Config is the global config
	Config = &ConfigInfo{}

	AskPassword = BoolP("ask-password", "", true, "Allow prompt for password for encrypted configuration.")
)

Global

View Source
var (
	// UserAgent set in the default Transport
	UserAgent = "rclone/" + Version

	// ErrorNotFoundInConfigFile is returned by NewFs if not found in config file
	ErrorNotFoundInConfigFile = errors.New("didn't find section in config file")
	ErrorCantPurge            = errors.New("can't purge directory")
	ErrorCantCopy             = errors.New("can't copy object - incompatible remotes")
	ErrorCantMove             = errors.New("can't move object - incompatible remotes")
	ErrorCantDirMove          = errors.New("can't move directory - incompatible remotes")
	ErrorDirExists            = errors.New("can't copy directory - destination already exists")
	ErrorCantSetModTime       = errors.New("can't set modified time")
	ErrorDirNotFound          = errors.New("directory not found")
	ErrorObjectNotFound       = errors.New("object not found")
	ErrorLevelNotSupported    = errors.New("level value not supported")
	ErrorListAborted          = errors.New("list aborted")
	ErrorListOnlyRoot         = errors.New("can only list from root")
	ErrorIsFile               = errors.New("is a file not a directory")
	ErrorNotAFile             = errors.New("is a not a regular file")
	ErrorNotDeleting          = errors.New("not deleting files as there were IO errors")
	ErrorCantMoveOverlapping  = errors.New("can't move files on overlapping remotes")
)

Globals

View Source
var ErrHashUnsupported = errors.New("hash type not supported")

ErrHashUnsupported should be returned by filesystem, if it is requested to deliver an unsupported hash type.

View Source
var HashWidth = map[HashType]int{
	HashMD5:  32,
	HashSHA1: 40,
}

HashWidth returns the width in characters for any HashType

View Source
var (
	Stats = NewStats()
)

Globals

View Source
var SupportedHashes = NewHashSet(HashMD5, HashSHA1)

SupportedHashes returns a set of all the supported hashes by HashStream and MultiHasher.

View Source
var Version = "v1.36-DEV"

Version of rclone

Functions

func AccountPart

func AccountPart(obj Object, in io.Reader) io.Reader

AccountPart accounts for part of a transfer

It disables the whole file counter and returns an io.Reader to wrap a segment of the transfer.

func Authorize

func Authorize(args []string)

Authorize is for remote authorization of headless machines.

It expects 1 or 3 arguments

rclone authorize "fs name"
rclone authorize "fs name" "client id" "client secret"

func BoolP

func BoolP(name, shorthand string, value bool, usage string) (out *bool)

BoolP defines a flag which can be overridden by an environment variable

It is a thin wrapper around pflag.BoolP

func CalculateModifyWindow

func CalculateModifyWindow(fs ...Fs)

CalculateModifyWindow works out modify window for Fses passed in - sets Config.ModifyWindow

This is the largest modify window of all the fses in use, and the user configured value

func CanServerSideMove

func CanServerSideMove(fdst Fs) bool

CanServerSideMove returns true if fdst support server side moves or server side copies

Some remotes simulate rename by server-side copy and delete, so include remotes that implements either Mover or Copier.

func Cat

func Cat(f Fs, w io.Writer, offset, count int64) error

Cat any files to the io.Writer

if offset == 0 it will be ignored if offset > 0 then the file will be seeked to that offset if offset < 0 then the file will be seeked that far from the end

if count < 0 then it will be ignored if count >= 0 then only that many characters will be output

func ChangePassword

func ChangePassword(name string) string

ChangePassword will query the user twice for the named password. If the same password is entered it is returned.

func Check

func Check(fdst, fsrc Fs) error

Check the files in fsrc and fdst according to Size and hash

func CheckClose

func CheckClose(c io.Closer, err *error)

CheckClose is a utility function used to check the return from Close in a defer statement.

func CheckDownload

func CheckDownload(fdst, fsrc Fs) error

CheckDownload checks the files in fsrc and fdst according to Size and the actual contents of the files.

func CheckEqualReaders

func CheckEqualReaders(in1, in2 io.Reader) (differ bool, err error)

CheckEqualReaders checks to see if in1 and in2 have the same content when read.

it returns true if differences were found

func CheckFn

func CheckFn(fdst, fsrc Fs, checkFunction func(a, b Object) (differ bool, noHash bool)) error

CheckFn checks the files in fsrc and fdst according to Size and hash using checkFunction on each file to check the hashes.

checkFunction sees if dst and src are identical

it returns true if differences were found it also returns whether it couldn't be hashed

func CheckIdentical

func CheckIdentical(dst, src Object) (differ bool, err error)

CheckIdentical checks to see if dst and src are identical by reading all their bytes if necessary.

it returns true if differences were found

func Choose

func Choose(what string, defaults, help []string, newOk bool) string

Choose one of the defaults or type a new string if newOk is set

func ChooseNumber

func ChooseNumber(what string, min, max int) int

ChooseNumber asks the user to enter a number between min and max inclusive prompting them with what.

func ChooseOption

func ChooseOption(o *Option) string

ChooseOption asks the user to choose an option

func ChooseRemote

func ChooseRemote() string

ChooseRemote chooses a remote name

func CleanUp

func CleanUp(f Fs) error

CleanUp removes the trash for the Fs

func Command

func Command(commands []string) byte

Command - choose one

func ConfigFileGet

func ConfigFileGet(section, key string, defaultVal ...string) string

ConfigFileGet gets the config key under section returning the default or empty string if not set.

It looks up defaults in the environment if they are present

func ConfigFileGetBool

func ConfigFileGetBool(section, key string, defaultVal ...bool) bool

ConfigFileGetBool gets the config key under section returning the default or false if not set.

It looks up defaults in the environment if they are present

func ConfigFileGetInt

func ConfigFileGetInt(section, key string, defaultVal ...int) int

ConfigFileGetInt gets the config key under section returning the default or 0 if not set.

It looks up defaults in the environment if they are present

func ConfigFileSections

func ConfigFileSections() []string

ConfigFileSections returns the sections in the config file including any defined by environment variables.

func ConfigFileSet

func ConfigFileSet(section, key, value string)

ConfigFileSet sets the key in section to value. It doesn't save the config file.

func ConfigSetValueAndSave

func ConfigSetValueAndSave(name, key, value string) (err error)

ConfigSetValueAndSave sets the key to the value and saves just that value in the config file. It loads the old config file in from disk first and overwrites the given value only.

func Confirm

func Confirm() bool

Confirm asks the user for Yes or No and returns true or false

func Copy

func Copy(f Fs, dst Object, remote string, src Object) (err error)

Copy src object to dst or f if nil. If dst is nil then it uses remote as the name of the new object.

func CopyDir

func CopyDir(fdst, fsrc Fs) error

CopyDir copies fsrc into fdst

func CopyFile

func CopyFile(fdst Fs, fsrc Fs, dstFileName string, srcFileName string) (err error)

CopyFile moves a single file possibly to a new name

func CopyRemote

func CopyRemote(name string)

CopyRemote copies a config section

func Count

func Count(f Fs) (objects int64, size int64, err error)

Count counts the objects and their sizes in the Fs

Obeys includes and excludes

func CountP

func CountP(name, shorthand string, usage string) (out *int)

CountP defines a flag which can be overridden by an environment variable

It is a thin wrapper around pflag.CountP

func Debugf

func Debugf(o interface{}, text string, args ...interface{})

Debugf writes debugging output for this Object or Fs. Use this for debug only. The user must have to specify -vv to see this.

func Deduplicate

func Deduplicate(f Fs, mode DeduplicateMode) error

Deduplicate interactively finds duplicate files and offers to delete all but one or rename them to be different. Only useful with Google Drive which can have duplicate file names.

func Delete

func Delete(f Fs) error

Delete removes all the contents of a container. Unlike Purge, it obeys includes and excludes.

func DeleteFile

func DeleteFile(dst Object) (err error)

DeleteFile deletes a single file respecting --dry-run and accumulating stats and errors.

If useBackupDir is set and --backup-dir is in effect then it moves the file to there instead of deleting

func DeleteFiles

func DeleteFiles(toBeDeleted ObjectsChan) error

DeleteFiles removes all the files passed in the channel

func DeleteRemote

func DeleteRemote(name string)

DeleteRemote gets the user to delete a remote

func DurationP

func DurationP(name, shorthand string, value time.Duration, usage string) (out *time.Duration)

DurationP defines a flag which can be overridden by an environment variable

It is a thin wrapper around pflag.DurationP

func EditConfig

func EditConfig()

EditConfig edits the config file interactively

func EditRemote

func EditRemote(fs *RegInfo, name string)

EditRemote gets the user to edit a remote

func Equal

func Equal(src, dst Object) bool

Equal checks to see if the src and dst objects are equal by looking at size, mtime and hash

If the src and dst size are different then it is considered to be not equal. If --size-only is in effect then this is the only check that is done. If --ignore-size is in effect then this check is skipped and the files are considered the same size.

If the size is the same and the mtime is the same then it is considered to be equal. This check is skipped if using --checksum.

If the size is the same and mtime is different, unreadable or --checksum is set and the hash is the same then the file is considered to be equal. In this case the mtime on the dst is updated if --checksum is not set.

Otherwise the file is considered to be not equal including if there were errors reading info.

func Errorf

func Errorf(o interface{}, text string, args ...interface{})

Errorf writes error log output for this Object or Fs. It should always be seen by the user.

func FatalError

func FatalError(err error) error

FatalError makes an error which indicates it is a fatal error and the sync should stop.

func GetPassword

func GetPassword(prompt string) string

GetPassword asks the user for a password with the prompt given.

func HashEquals

func HashEquals(src, dst string) bool

HashEquals checks to see if src == dst, but ignores empty strings and returns true if either is empty.

func HashStream

func HashStream(r io.Reader) (map[HashType]string, error)

HashStream will calculate hashes of all supported hash types.

func HashStreamTypes

func HashStreamTypes(r io.Reader, set HashSet) (map[HashType]string, error)

HashStreamTypes will calculate hashes of the requested hash types.

func Infof

func Infof(o interface{}, text string, args ...interface{})

Infof writes info on transfers for this Object or Fs. Use this level for logging transfers, deletions and things which should appear with the -v flag.

func InitLogging

func InitLogging()

InitLogging start the logging as per the command line flags

func IntP

func IntP(name, shorthand string, value int, usage string) (out *int)

IntP defines a flag which can be overridden by an environment variable

It is a thin wrapper around pflag.IntP

func IsFatalError

func IsFatalError(err error) bool

IsFatalError returns true if err conforms to the Fatal interface and calling the Fatal method returns true.

func IsNoRetryError

func IsNoRetryError(err error) bool

IsNoRetryError returns true if err conforms to the NoRetry interface and calling the NoRetry method returns true.

func IsRetryError

func IsRetryError(err error) bool

IsRetryError returns true if err conforms to the Retry interface and calling the Retry method returns true.

func List

func List(f Fs, w io.Writer) error

List the Fs to the supplied writer

Shows size and path - obeys includes and excludes

Lists in parallel which may get them out of order

func ListDir

func ListDir(f Fs, w io.Writer) error

ListDir lists the directories/buckets/containers in the Fs to the supplied writer

func ListFn

func ListFn(f Fs, fn func(Object)) error

ListFn lists the Fs to the supplied function

Lists in parallel which may get them out of order

func ListLong

func ListLong(f Fs, w io.Writer) error

ListLong lists the Fs to the supplied writer

Shows size, mod time and path - obeys includes and excludes

Lists in parallel which may get them out of order

func LoadConfig

func LoadConfig()

LoadConfig loads the config file

func Logf

func Logf(o interface{}, text string, args ...interface{})

Logf writes log output for this Object or Fs. This should be considered to be Info level logging. It is the default level. By default rclone should not log very much so only use this for important things the user should see. The user can filter these out with the -q flag.

func Md5sum

func Md5sum(f Fs, w io.Writer) error

Md5sum list the Fs to the supplied writer

Produces the same output as the md5sum command - obeys includes and excludes

Lists in parallel which may get them out of order

func MimeType

func MimeType(o ObjectInfo) (mimeType string)

MimeType returns the MimeType from the object, either by calling the MimeTyper interface or using MimeTypeFromName

func MimeTypeFromName

func MimeTypeFromName(remote string) (mimeType string)

MimeTypeFromName returns a guess at the mime type from the name

func Mkdir

func Mkdir(f Fs, dir string) error

Mkdir makes a destination directory or container

func Move

func Move(fdst Fs, dst Object, remote string, src Object) (err error)

Move src object to dst or fdst if nil. If dst is nil then it uses remote as the name of the new object.

func MoveDir

func MoveDir(fdst, fsrc Fs) error

MoveDir moves fsrc into fdst

func MoveFile

func MoveFile(fdst Fs, fsrc Fs, dstFileName string, srcFileName string) (err error)

MoveFile moves a single file possibly to a new name

func MustObscure

func MustObscure(x string) string

MustObscure obscures a value, exiting with a fatal error if it failed

func MustReveal

func MustReveal(x string) string

MustReveal reveals an obscured value, exiting with a fatal error if it failed

func NeedTransfer

func NeedTransfer(dst, src Object) bool

NeedTransfer checks to see if src needs to be copied to dst using the current config.

Returns a flag which indicates whether the file needs to be transferred or not.

func NewRemote

func NewRemote(name string)

NewRemote make a new remote from its name

func NewRemoteName

func NewRemoteName() (name string)

NewRemoteName asks the user for a name for a remote

func NoRetryError

func NoRetryError(err error) error

NoRetryError makes an error which indicates the sync shouldn't be retried.

func Obscure

func Obscure(x string) (string, error)

Obscure a value

This is done by encrypting with AES-CTR

func OkRemote

func OkRemote(name string) bool

OkRemote prints the contents of the remote and ask if it is OK

func OpenOptionAddHTTPHeaders

func OpenOptionAddHTTPHeaders(headers http.Header, options []OpenOption)

OpenOptionAddHTTPHeaders Sets each header found in options to the http.Header map provided the key was non empty.

func OpenOptionAddHeaders

func OpenOptionAddHeaders(options []OpenOption, headers map[string]string)

OpenOptionAddHeaders adds each header found in options to the headers map provided the key was non empty.

func OpenOptionHeaders

func OpenOptionHeaders(options []OpenOption) (headers map[string]string)

OpenOptionHeaders adds each header found in options to the headers map provided the key was non empty.

It returns a nil map if options was empty

func Overlapping

func Overlapping(fdst, fsrc Info) bool

Overlapping returns true if fdst and fsrc point to the same underlying Fs and they overlap.

func ParseDuration

func ParseDuration(age string) (time.Duration, error)

ParseDuration parses a duration string. Accept ms|s|m|h|d|w|M|y suffixes. Defaults to second if not provided

func Purge

func Purge(f Fs) error

Purge removes a container and all of its contents

func ReadFill

func ReadFill(r io.Reader, buf []byte) (n int, err error)

ReadFill reads as much data from r into buf as it can

It reads until the buffer is full or r.Read returned an error.

This is io.ReadFull but when you just want as much data as possible, not an exact size of block.

func ReadLine

func ReadLine() string

ReadLine reads some input

func ReadPassword

func ReadPassword() string

ReadPassword reads a password without echoing it to the terminal.

func Register

func Register(info *RegInfo)

Register a filesystem

Fs modules should use this in an init() function

func RemoteConfig

func RemoteConfig(name string)

RemoteConfig runs the config helper for the remote if needed

func RenameRemote

func RenameRemote(name string)

RenameRemote renames a config section

func RetryError

func RetryError(err error) error

RetryError makes an error which indicates it would like to be retried

func RetryErrorf

func RetryErrorf(format string, a ...interface{}) error

RetryErrorf makes an error which indicates it would like to be retried

func Reveal

func Reveal(x string) (string, error)

Reveal an obscured value

func Rmdir

func Rmdir(f Fs, dir string) error

Rmdir removes a container but not if not empty

func Rmdirs

func Rmdirs(f Fs, dir string) error

Rmdirs removes any empty directories (or directories only containing empty directories) under f, including f.

func Same

func Same(fdst, fsrc Info) bool

Same returns true if fdst and fsrc point to the same underlying Fs

func SameConfig

func SameConfig(fdst, fsrc Info) bool

SameConfig returns true if fdst and fsrc are using the same config file entry

func SaveConfig

func SaveConfig()

SaveConfig saves configuration file. if configKey has been set, the file will be encrypted.

func SetPassword

func SetPassword()

SetPassword will allow the user to modify the current configuration encryption settings.

func Sha1sum

func Sha1sum(f Fs, w io.Writer) error

Sha1sum list the Fs to the supplied writer

Obeys includes and excludes

Lists in parallel which may get them out of order

func ShouldRetry

func ShouldRetry(err error) bool

ShouldRetry looks at an error and tries to work out if retrying the operation that caused it would be a good idea. It returns true if the error implements Timeout() or Temporary() or if the error indicates a premature closing of the connection.

func ShouldRetryHTTP

func ShouldRetryHTTP(resp *http.Response, retryErrorCodes []int) bool

ShouldRetryHTTP returns a boolean as to whether this resp deserves. It checks to see if the HTTP response code is in the slice retryErrorCodes.

func ShowRemote

func ShowRemote(name string)

ShowRemote shows the contents of the remote

func ShowRemotes

func ShowRemotes()

ShowRemotes shows an overview of the config file

func StringArrayP

func StringArrayP(name, shorthand string, value []string, usage string) (out *[]string)

StringArrayP defines a flag which can be overridden by an environment variable

It sets one value only - command line flags can be used to set more.

It is a thin wrapper around pflag.StringArrayP

func StringP

func StringP(name, shorthand string, value string, usage string) (out *string)

StringP defines a flag which can be overridden by an environment variable

It is a thin wrapper around pflag.StringP

func Sync

func Sync(fdst, fsrc Fs) error

Sync fsrc into fdst

func TryRmdir

func TryRmdir(f Fs, dir string) error

TryRmdir removes a container but not if not empty. It doesn't count errors but may return one.

func VarP

func VarP(value pflag.Value, name, shorthand, usage string)

VarP defines a flag which can be overridden by an environment variable

It is a thin wrapper around pflag.VarP

Types

type Account

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

Account limits and accounts for one transfer

func AccountByPart

func AccountByPart(obj Object) *Account

AccountByPart turns off whole file accounting

Returns the current account or nil if not found

func NewAccount

func NewAccount(in io.ReadCloser, obj Object) *Account

NewAccount makes a Account reader for an object

func NewAccountSizeName

func NewAccountSizeName(in io.ReadCloser, size int64, name string) *Account

NewAccountSizeName makes a Account reader for an io.ReadCloser of the given size and name

func (*Account) Close

func (acc *Account) Close() error

Close the object

func (*Account) ETA

func (acc *Account) ETA() (eta time.Duration, ok bool)

ETA returns the ETA of the current operation, rounded to full seconds. If the ETA cannot be determined 'ok' returns false.

func (*Account) GetReader

func (acc *Account) GetReader() io.ReadCloser

GetReader returns the underlying io.ReadCloser

func (*Account) Progress

func (acc *Account) Progress() (bytes, size int64)

Progress returns bytes read as well as the size. Size can be <= 0 if the size is unknown.

func (*Account) Read

func (acc *Account) Read(p []byte) (n int, err error)

Read bytes from the object - see io.Reader

func (*Account) Speed

func (acc *Account) Speed() (bps, current float64)

Speed returns the speed of the current file transfer in bytes per second, as well a an exponentially weighted moving average If no read has completed yet, 0 is returned for both values.

func (*Account) StopBuffering

func (acc *Account) StopBuffering()

StopBuffering stops the async buffer doing any more buffering

func (*Account) String

func (acc *Account) String() string

String produces stats for this file

func (*Account) UpdateReader

func (acc *Account) UpdateReader(in io.ReadCloser)

UpdateReader updates the underlying io.ReadCloser

func (*Account) WithBuffer

func (acc *Account) WithBuffer() *Account

WithBuffer - If the file is above a certain size it adds an Async reader

type BasicInfo

type BasicInfo interface {
	// String returns a description of the Object
	String() string

	// Remote returns the remote path
	Remote() string

	// ModTime returns the modification date of the file
	// It should return a best guess if one isn't available
	ModTime() time.Time

	// Size returns the size of the file
	Size() int64
}

BasicInfo common interface for Dir and Object providing the very basic attributes of an object.

type BwTimeSlot

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

BwTimeSlot represents a bandwidth configuration at a point in time.

type BwTimetable

type BwTimetable []BwTimeSlot

BwTimetable contains all configured time slots.

func (BwTimetable) LimitAt

func (x BwTimetable) LimitAt(tt time.Time) BwTimeSlot

LimitAt returns a BwTimeSlot for the time requested.

func (*BwTimetable) Set

func (x *BwTimetable) Set(s string) error

Set the bandwidth timetable.

func (BwTimetable) String

func (x BwTimetable) String() string

String returns a printable representation of BwTimetable.

func (BwTimetable) Type

func (x BwTimetable) Type() string

Type of the value

type CleanUpper

type CleanUpper interface {
	// CleanUp the trash in the Fs
	//
	// Implement this if you have a way of emptying the trash or
	// otherwise cleaning up old versions of files.
	CleanUp() error
}

CleanUpper is an optional interfaces for Fs

type ConfigInfo

type ConfigInfo struct {
	LogLevel           LogLevel
	DryRun             bool
	CheckSum           bool
	SizeOnly           bool
	IgnoreTimes        bool
	IgnoreExisting     bool
	ModifyWindow       time.Duration
	Checkers           int
	Transfers          int
	ConnectTimeout     time.Duration // Connect timeout
	Timeout            time.Duration // Data channel timeout
	DumpHeaders        bool
	DumpBodies         bool
	DumpAuth           bool
	Filter             *Filter
	InsecureSkipVerify bool // Skip server certificate verification
	DeleteMode         DeleteMode
	TrackRenames       bool // Track file renames.
	LowLevelRetries    int
	UpdateOlder        bool // Skip files that are newer on the destination
	NoGzip             bool // Disable compression
	MaxDepth           int
	IgnoreSize         bool
	IgnoreChecksum     bool
	NoTraverse         bool
	NoUpdateModTime    bool
	DataRateUnit       string
	BackupDir          string
	Suffix             string
	BufferSize         SizeSuffix
}

ConfigInfo is filesystem config options

func (*ConfigInfo) Client

func (ci *ConfigInfo) Client() *http.Client

Client returns an http.Client with the correct timeouts

func (*ConfigInfo) Transport

func (ci *ConfigInfo) Transport() http.RoundTripper

Transport returns an http.RoundTripper with the correct timeouts

type Copier

type Copier interface {
	// Copy src to this remote using server side copy operations.
	//
	// This is stored with the remote path given
	//
	// It returns the destination Object and a possible error
	//
	// Will only be called if src.Fs().Name() == f.Name()
	//
	// If it isn't possible then return fs.ErrorCantCopy
	Copy(src Object, remote string) (Object, error)
}

Copier is an optional interface for Fs

type DeduplicateMode

type DeduplicateMode int

DeduplicateMode is how the dedupe command chooses what to do

const (
	DeduplicateInteractive DeduplicateMode = iota // interactively ask the user
	DeduplicateSkip                               // skip all conflicts
	DeduplicateFirst                              // choose the first object
	DeduplicateNewest                             // choose the newest object
	DeduplicateOldest                             // choose the oldest object
	DeduplicateRename                             // rename the objects
)

Deduplicate modes

func (*DeduplicateMode) Set

func (x *DeduplicateMode) Set(s string) error

Set a DeduplicateMode from a string

func (DeduplicateMode) String

func (x DeduplicateMode) String() string

func (*DeduplicateMode) Type

func (x *DeduplicateMode) Type() string

Type of the value

type DeleteMode

type DeleteMode byte

DeleteMode describes the possible delete modes in the config

const (
	DeleteModeOff DeleteMode = iota
	DeleteModeBefore
	DeleteModeDuring
	DeleteModeAfter
	DeleteModeOnly
	DeleteModeDefault = DeleteModeAfter
)

DeleteMode constants

type Dir

type Dir struct {
	Name  string    // name of the directory
	When  time.Time // modification or creation time - IsZero for unknown
	Bytes int64     // size of directory and contents -1 for unknown
	Count int64     // number of objects -1 for unknown
}

Dir describes a directory for directory/container/bucket lists

func (*Dir) ModTime

func (d *Dir) ModTime() time.Time

ModTime returns the modification date of the file It should return a best guess if one isn't available

func (*Dir) Remote

func (d *Dir) Remote() string

Remote returns the remote path

func (*Dir) Size

func (d *Dir) Size() int64

Size returns the size of the file

func (*Dir) String

func (d *Dir) String() string

String returns the name

type DirCacheFlusher

type DirCacheFlusher interface {
	// DirCacheFlush resets the directory cache - used in testing
	// as an optional interface
	DirCacheFlush()
}

DirCacheFlusher is an optional interface for Fs

type DirChan

type DirChan chan *Dir

DirChan is a channel of Dir objects

type DirEntries

type DirEntries []BasicInfo

DirEntries is a slice of Object or *Dir

func ListDirSorted

func ListDirSorted(fs Fs, includeAll bool, dir string) (entries DirEntries, err error)

ListDirSorted reads Object and *Dir into entries for the given Fs.

dir is the start directory, "" for root

If includeAll is specified all files will be added, otherwise only files passing the filter will be added.

Files will be returned in sorted order

func (DirEntries) Len

func (ds DirEntries) Len() int

Len is part of sort.Interface.

func (DirEntries) Less

func (ds DirEntries) Less(i, j int) bool

Less is part of sort.Interface.

func (DirEntries) Swap

func (ds DirEntries) Swap(i, j int)

Swap is part of sort.Interface.

type DirMover

type DirMover interface {
	// DirMove moves src, srcRemote to this remote at dstRemote
	// using server side move operations.
	//
	// Will only be called if src.Fs().Name() == f.Name()
	//
	// If it isn't possible then return fs.ErrorCantDirMove
	//
	// If destination exists then return fs.ErrorDirExists
	DirMove(src Fs, srcRemote, dstRemote string) error
}

DirMover is an optional interface for Fs

type Fataler

type Fataler interface {
	error
	Fatal() bool
}

Fataler is an optional interface for error as to whether the operation should cause the entire operation to finish immediately.

This should be returned from Update or Put methods as required

type Features

type Features struct {
	// Feature flags
	CaseInsensitive bool
	DuplicateFiles  bool
	ReadMimeType    bool
	WriteMimeType   bool

	// Purge all files in the root and the root directory
	//
	// Implement this if you have a way of deleting all the files
	// quicker than just running Remove() on the result of List()
	//
	// Return an error if it doesn't exist
	Purge func() error

	// Copy src to this remote using server side copy operations.
	//
	// This is stored with the remote path given
	//
	// It returns the destination Object and a possible error
	//
	// Will only be called if src.Fs().Name() == f.Name()
	//
	// If it isn't possible then return fs.ErrorCantCopy
	Copy func(src Object, remote string) (Object, error)

	// Move src to this remote using server side move operations.
	//
	// This is stored with the remote path given
	//
	// It returns the destination Object and a possible error
	//
	// Will only be called if src.Fs().Name() == f.Name()
	//
	// If it isn't possible then return fs.ErrorCantMove
	Move func(src Object, remote string) (Object, error)

	// DirMove moves src, srcRemote to this remote at dstRemote
	// using server side move operations.
	//
	// Will only be called if src.Fs().Name() == f.Name()
	//
	// If it isn't possible then return fs.ErrorCantDirMove
	//
	// If destination exists then return fs.ErrorDirExists
	DirMove func(src Fs, srcRemote, dstRemote string) error

	// UnWrap returns the Fs that this Fs is wrapping
	UnWrap func() Fs

	// DirCacheFlush resets the directory cache - used in testing
	// as an optional interface
	DirCacheFlush func()

	// Put in to the remote path with the modTime given of the given size
	//
	// May create the object even if it returns an error - if so
	// will return the object and the error, otherwise will return
	// nil and the error
	//
	// May create duplicates or return errors if src already
	// exists.
	PutUnchecked func(in io.Reader, src ObjectInfo) (Object, error)

	// CleanUp the trash in the Fs
	//
	// Implement this if you have a way of emptying the trash or
	// otherwise cleaning up old versions of files.
	CleanUp func() error
}

Features describe the optional features of the Fs

func (*Features) Fill

func (ft *Features) Fill(f Fs) *Features

Fill fills in the function pointers in the Features struct from the optional interfaces. It returns the original updated Features struct passed in.

func (*Features) Mask

func (ft *Features) Mask(f Fs) *Features

Mask the Features with the Fs passed in

Only optional features which are implemented in both the original Fs AND the one passed in will be advertised. Any features which aren't in both will be set to false/nil, except for UnWrap which will be left untouched.

func (*Features) Wrap

func (ft *Features) Wrap(f Fs) *Features

Wrap makes a Copy of the features passed in, overriding the UnWrap method only if available in f.

type FilesMap

type FilesMap map[string]struct{}

FilesMap describes the map of files to transfer

type Filter

type Filter struct {
	DeleteExcluded bool
	MinSize        int64
	MaxSize        int64
	ModTimeFrom    time.Time
	ModTimeTo      time.Time
	// contains filtered or unexported fields
}

Filter describes any filtering in operation

func NewFilter

func NewFilter() (f *Filter, err error)

NewFilter parses the command line options and creates a Filter object

func (*Filter) Add

func (f *Filter) Add(Include bool, glob string) error

Add adds a filter rule with include or exclude status indicated

func (*Filter) AddFile

func (f *Filter) AddFile(file string) error

AddFile adds a single file to the files from list

func (*Filter) AddRule

func (f *Filter) AddRule(rule string) error

AddRule adds a filter rule with include/exclude indicated by the prefix

These are

  • glob
  • glob !

'+' includes the glob, '-' excludes it and '!' resets the filter list

Line comments may be introduced with '#' or ';'

func (*Filter) Clear

func (f *Filter) Clear()

Clear clears all the filter rules

func (*Filter) DumpFilters

func (f *Filter) DumpFilters() string

DumpFilters dumps the filters in textual form, 1 per line

func (*Filter) Files

func (f *Filter) Files() FilesMap

Files returns all the files from the `--files-from` list

It may be nil if the list is empty

func (*Filter) InActive

func (f *Filter) InActive() bool

InActive returns false if any filters are active

func (*Filter) Include

func (f *Filter) Include(remote string, size int64, modTime time.Time) bool

Include returns whether this object should be included into the sync or not

func (*Filter) IncludeDirectory

func (f *Filter) IncludeDirectory(remote string) bool

IncludeDirectory returns whether this directory should be included in the sync or not.

func (*Filter) IncludeObject

func (f *Filter) IncludeObject(o Object) bool

IncludeObject returns whether this object should be included into the sync or not. This is a convenience function to avoid calling o.ModTime(), which is an expensive operation.

type Fs

type Fs interface {
	Info
	ListFser

	// Put in to the remote path with the modTime given of the given size
	//
	// May create the object even if it returns an error - if so
	// will return the object and the error, otherwise will return
	// nil and the error
	Put(in io.Reader, src ObjectInfo) (Object, error)

	// Mkdir makes the directory (container, bucket)
	//
	// Shouldn't return an error if it already exists
	Mkdir(dir string) error

	// Rmdir removes the directory (container, bucket) if empty
	//
	// Return an error if it doesn't exist or isn't empty
	Rmdir(dir string) error
}

Fs is the interface a cloud storage system must provide

func NewFs

func NewFs(path string) (Fs, error)

NewFs makes a new Fs object from the path

The path is of the form remote:path

Remotes are looked up in the config file. If the remote isn't found then NotFoundInConfigFile will be returned.

On Windows avoid single character remote names as they can be mixed up with drive letters.

type HTTPOption

type HTTPOption struct {
	Key   string
	Value string
}

HTTPOption defines a general purpose HTTP option

func (*HTTPOption) Header

func (o *HTTPOption) Header() (key string, value string)

Header formats the option as an http header

func (*HTTPOption) Mandatory

func (o *HTTPOption) Mandatory() bool

Mandatory returns whether the option must be parsed or can be ignored

func (*HTTPOption) String

func (o *HTTPOption) String() string

String formats the option into human readable form

type HashSet

type HashSet int

A HashSet Indicates one or more hash types.

func NewHashSet

func NewHashSet(t ...HashType) HashSet

NewHashSet will create a new hash set with the hash types supplied

func (*HashSet) Add

func (h *HashSet) Add(t ...HashType) HashSet

Add one or more hash types to the set. Returns the modified hash set.

func (HashSet) Array

func (h HashSet) Array() (ht []HashType)

Array returns an array of all hash types in the set

func (HashSet) Contains

func (h HashSet) Contains(t HashType) bool

Contains returns true if the

func (HashSet) Count

func (h HashSet) Count() int

Count returns the number of hash types in the set

func (HashSet) GetOne

func (h HashSet) GetOne() HashType

GetOne will return a hash type. Currently the first is returned, but it could be improved to return the strongest.

func (HashSet) Overlap

func (h HashSet) Overlap(t HashSet) HashSet

Overlap returns the overlapping hash types

func (HashSet) String

func (h HashSet) String() string

String returns a string representation of the hash set. The function will panic if it contains an unknown type.

func (HashSet) SubsetOf

func (h HashSet) SubsetOf(c HashSet) bool

SubsetOf will return true if all types of h is present in the set c

type HashType

type HashType int

HashType indicates a standard hashing algorithm

const (
	// HashMD5 indicates MD5 support
	HashMD5 HashType = 1 << iota

	// HashSHA1 indicates SHA-1 support
	HashSHA1

	// HashNone indicates no hashes are supported
	HashNone HashType = 0
)

func CheckHashes

func CheckHashes(src, dst Object) (equal bool, hash HashType, err error)

CheckHashes checks the two files to see if they have common known hash types and compares them

Returns

equal - which is equality of the hashes

hash - the HashType. This is HashNone if either of the hashes were unset or a compatible hash couldn't be found.

err - may return an error which will already have been logged

If an error is returned it will return equal as false

func (HashType) String

func (h HashType) String() string

String returns a string representation of the hash type. The function will panic if the hash type is unknown.

type Info

type Info interface {
	// Name of the remote (as passed into NewFs)
	Name() string

	// Root of the remote (as passed into NewFs)
	Root() string

	// String returns a description of the FS
	String() string

	// Precision of the ModTimes in this Fs
	Precision() time.Duration

	// Returns the supported hash types of the filesystem
	Hashes() HashSet

	// Features returns the optional features of this Fs
	Features() *Features
}

Info provides an interface to reading information about a filesystem.

type ListFser

type ListFser interface {
	// List the objects and directories of the Fs starting from dir
	//
	// dir should be "" to start from the root, and should not
	// have trailing slashes.
	//
	// This should return ErrDirNotFound (using out.SetError())
	// if the directory isn't found.
	//
	// Fses must support recursion levels of fs.MaxLevel and 1.
	// They may return ErrorLevelNotSupported otherwise.
	List(out ListOpts, dir string)

	// NewObject finds the Object at remote.  If it can't be found
	// it returns the error ErrorObjectNotFound.
	NewObject(remote string) (Object, error)
}

ListFser is the interface for listing a remote Fs

type ListOpts

type ListOpts interface {
	// Add an object to the output.
	// If the function returns true, the operation has been aborted.
	// Multiple goroutines can safely add objects concurrently.
	Add(obj Object) (abort bool)

	// Add a directory to the output.
	// If the function returns true, the operation has been aborted.
	// Multiple goroutines can safely add objects concurrently.
	AddDir(dir *Dir) (abort bool)

	// IncludeDirectory returns whether this directory should be
	// included in the listing (and recursed into or not).
	IncludeDirectory(remote string) bool

	// SetError will set an error state, and will cause the listing to
	// be aborted.
	// Multiple goroutines can set the error state concurrently,
	// but only the first will be returned to the caller.
	SetError(err error)

	// Level returns the level it should recurse to.  Fses may
	// ignore this in which case the listing will be less
	// efficient.
	Level() int

	// Buffer returns the channel depth in use
	Buffer() int

	// Finished should be called when listing is finished
	Finished()

	// IsFinished returns whether Finished or SetError have been called
	IsFinished() bool
}

ListOpts describes the interface used for Fs.List operations

type Lister

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

Lister objects are used for controlling listing of Fs objects

func NewLister

func NewLister() *Lister

NewLister creates a Lister object.

The default channel buffer size will be Config.Checkers unless overridden with SetBuffer. The default level will be infinite.

func (*Lister) Add

func (o *Lister) Add(obj Object) (abort bool)

Add an object to the output. If the function returns true, the operation has been aborted. Multiple goroutines can safely add objects concurrently.

func (*Lister) AddDir

func (o *Lister) AddDir(dir *Dir) (abort bool)

AddDir will a directory to the output. If the function returns true, the operation has been aborted. Multiple goroutines can safely add objects concurrently.

func (*Lister) Buffer

func (o *Lister) Buffer() int

Buffer gets the channel buffer size in use

func (*Lister) Error

func (o *Lister) Error() error

Error returns a globally application error that's been set on the Lister object.

func (*Lister) Finished

func (o *Lister) Finished()

Finished should be called when listing is finished

func (*Lister) Get

func (o *Lister) Get() (Object, *Dir, error)

Get an object from the listing. Will return either an object or a directory, never both. Will return (nil, nil, nil) when all objects have been returned.

func (*Lister) GetAll

func (o *Lister) GetAll() (objs []Object, dirs []*Dir, err error)

GetAll gets all the objects and dirs from the listing.

func (*Lister) GetDir

func (o *Lister) GetDir() (*Dir, error)

GetDir will return a directory from the listing. It will skip over any objects. Will return (nil, nil) when all objects have been returned.

func (*Lister) GetDirs

func (o *Lister) GetDirs() (dirs []*Dir, err error)

GetDirs will return a slice of directories from the listing. It will skip over any objects.

func (*Lister) GetObject

func (o *Lister) GetObject() (Object, error)

GetObject will return an object from the listing. It will skip over any directories. Will return (nil, nil) when all objects have been returned.

func (*Lister) GetObjects

func (o *Lister) GetObjects() (objs []Object, err error)

GetObjects will return a slice of object from the listing. It will skip over any directories.

func (*Lister) IncludeDirectory

func (o *Lister) IncludeDirectory(remote string) bool

IncludeDirectory returns whether this directory should be included in the listing (and recursed into or not).

func (*Lister) IsFinished

func (o *Lister) IsFinished() bool

IsFinished returns whether the directory listing is finished or not

func (*Lister) Level

func (o *Lister) Level() int

Level gets the recursion level for this listing.

Fses may ignore this, but should implement it for improved efficiency if possible.

Level 1 means list just the contents of the directory

Each returned item must have less than level `/`s in.

func (*Lister) SetBuffer

func (o *Lister) SetBuffer(buffer int) *Lister

SetBuffer sets the channel buffer size in use. Must be called before Start().

func (*Lister) SetError

func (o *Lister) SetError(err error)

SetError will set an error state, and will cause the listing to be aborted. Multiple goroutines can set the error state concurrently, but only the first will be returned to the caller.

func (*Lister) SetFilter

func (o *Lister) SetFilter(filter *Filter) *Lister

SetFilter sets the Filter that is in use. It defaults to no filtering. Must be called before Start().

func (*Lister) SetLevel

func (o *Lister) SetLevel(level int) *Lister

SetLevel sets the level to recurse to. It returns same Lister that was passed in for convenience. If Level is < 0 then it sets it to infinite. Must be called before Start().

func (*Lister) Start

func (o *Lister) Start(f ListFser, dir string) *Lister

Start starts a go routine listing the Fs passed in. It returns the same Lister that was passed in for convenience.

type LogLevel

type LogLevel byte

LogLevel describes rclone's logs. These are a subset of the syslog log levels.

const (
	LogLevelEmergency LogLevel = iota
	LogLevelAlert
	LogLevelCritical
	LogLevelError // Error - can't be suppressed
	LogLevelWarning
	LogLevelNotice // Normal logging, -q suppresses
	LogLevelInfo   // Transfers, needs -v
	LogLevelDebug  // Debug level, needs -vv
)

Log levels. These are the syslog levels of which we only use a subset.

LOG_EMERG      system is unusable
LOG_ALERT      action must be taken immediately
LOG_CRIT       critical conditions
LOG_ERR        error conditions
LOG_WARNING    warning conditions
LOG_NOTICE     normal, but significant, condition
LOG_INFO       informational message
LOG_DEBUG      debug-level message

func (LogLevel) String

func (l LogLevel) String() string

String turns a LogLevel into a string

type MimeTyper

type MimeTyper interface {
	// MimeType returns the content type of the Object if
	// known, or "" if not
	MimeType() string
}

MimeTyper is an optional interface for Object

type Mover

type Mover interface {
	// Move src to this remote using server side move operations.
	//
	// This is stored with the remote path given
	//
	// It returns the destination Object and a possible error
	//
	// Will only be called if src.Fs().Name() == f.Name()
	//
	// If it isn't possible then return fs.ErrorCantMove
	Move(src Object, remote string) (Object, error)
}

Mover is an optional interface for Fs

type MultiHasher

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

A MultiHasher will construct various hashes on all incoming writes.

func NewMultiHasher

func NewMultiHasher() *MultiHasher

NewMultiHasher will return a hash writer that will write all supported hash types.

func NewMultiHasherTypes

func NewMultiHasherTypes(set HashSet) (*MultiHasher, error)

NewMultiHasherTypes will return a hash writer that will write the requested hash types.

func (*MultiHasher) Size

func (m *MultiHasher) Size() int64

Size returns the number of bytes written

func (*MultiHasher) Sums

func (m *MultiHasher) Sums() map[HashType]string

Sums returns the sums of all accumulated hashes as hex encoded strings.

func (*MultiHasher) Write

func (m *MultiHasher) Write(p []byte) (n int, err error)

type NoRetrier

type NoRetrier interface {
	error
	NoRetry() bool
}

NoRetrier is an optional interface for error as to whether the operation should not be retried at a high level.

If only NoRetry errors are returned in a sync then the sync won't be retried.

This should be returned from Update or Put methods as required

type Object

type Object interface {
	ObjectInfo

	// SetModTime sets the metadata on the object to set the modification date
	SetModTime(time.Time) error

	// Open opens the file for read.  Call Close() on the returned io.ReadCloser
	Open(options ...OpenOption) (io.ReadCloser, error)

	// Update in to the object with the modTime given of the given size
	Update(in io.Reader, src ObjectInfo) error

	// Removes this object
	Remove() error
}

Object is a filesystem like object provided by an Fs

type ObjectInfo

type ObjectInfo interface {
	BasicInfo

	// Fs returns read only access to the Fs that this object is part of
	Fs() Info

	// Hash returns the selected checksum of the file
	// If no checksum is available it returns ""
	Hash(HashType) (string, error)

	// Storable says whether this object can be stored
	Storable() bool
}

ObjectInfo contains information about an object.

func NewStaticObjectInfo

func NewStaticObjectInfo(remote string, modTime time.Time, size int64, storable bool, hashes map[HashType]string, fs Info) ObjectInfo

NewStaticObjectInfo returns a static ObjectInfo If hashes is nil and fs is not nil, the hash map will be replaced with empty hashes of the types supported by the fs.

type ObjectPair

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

ObjectPair is a pair of Objects used to describe a potential copy operation.

type ObjectPairChan

type ObjectPairChan chan ObjectPair

ObjectPairChan is a channel of ObjectPair

type Objects

type Objects []Object

Objects is a slice of Object~s

type ObjectsChan

type ObjectsChan chan Object

ObjectsChan is a channel of Objects

type OpenOption

type OpenOption interface {
	fmt.Stringer

	// Header returns the option as an HTTP header
	Header() (key string, value string)

	// Mandatory returns whether this option can be ignored or not
	Mandatory() bool
}

OpenOption is an interface describing options for Open

type Option

type Option struct {
	Name       string
	Help       string
	Optional   bool
	IsPassword bool
	Examples   OptionExamples
}

Option is describes an option for the config wizard

type OptionExample

type OptionExample struct {
	Value string
	Help  string
}

OptionExample describes an example for an Option

type OptionExamples

type OptionExamples []OptionExample

OptionExamples is a slice of examples

func (OptionExamples) Len

func (os OptionExamples) Len() int

Len is part of sort.Interface.

func (OptionExamples) Less

func (os OptionExamples) Less(i, j int) bool

Less is part of sort.Interface.

func (OptionExamples) Sort

func (os OptionExamples) Sort()

Sort sorts an OptionExamples

func (OptionExamples) Swap

func (os OptionExamples) Swap(i, j int)

Swap is part of sort.Interface.

type Purger

type Purger interface {
	// Purge all files in the root and the root directory
	//
	// Implement this if you have a way of deleting all the files
	// quicker than just running Remove() on the result of List()
	//
	// Return an error if it doesn't exist
	Purge() error
}

Purger is an optional interfaces for Fs

type PutUncheckeder

type PutUncheckeder interface {
	// Put in to the remote path with the modTime given of the given size
	//
	// May create the object even if it returns an error - if so
	// will return the object and the error, otherwise will return
	// nil and the error
	//
	// May create duplicates or return errors if src already
	// exists.
	PutUnchecked(in io.Reader, src ObjectInfo) (Object, error)
}

PutUncheckeder is an optional interface for Fs

type RangeOption

type RangeOption struct {
	Start int64
	End   int64
}

RangeOption defines an HTTP Range option with start and end. If either start or end are < 0 then they will be omitted.

func (*RangeOption) Header

func (o *RangeOption) Header() (key string, value string)

Header formats the option as an http header

func (*RangeOption) Mandatory

func (o *RangeOption) Mandatory() bool

Mandatory returns whether the option must be parsed or can be ignored

func (*RangeOption) String

func (o *RangeOption) String() string

String formats the option into human readable form

type RegInfo

type RegInfo struct {
	// Name of this fs
	Name string
	// Description of this fs - defaults to Name
	Description string
	// Create a new file system.  If root refers to an existing
	// object, then it should return a Fs which which points to
	// the parent of that object and ErrorIsFile.
	NewFs func(name string, root string) (Fs, error)
	// Function to call to help with config
	Config func(string)
	// Options for the Fs configuration
	Options []Option
}

RegInfo provides information about a filesystem

func Find

func Find(name string) (*RegInfo, error)

Find looks for an Info object for the name passed in

Services are looked up in the config file

func MustFind

func MustFind(name string) *RegInfo

MustFind looks for an Info object for the type name passed in

Services are looked up in the config file

Exits with a fatal error if not found

func MustFindByName

func MustFindByName(name string) *RegInfo

MustFindByName finds the RegInfo for the remote name passed in or exits with a fatal error.

func ParseRemote

func ParseRemote(path string) (fsInfo *RegInfo, configName, fsPath string, err error)

ParseRemote deconstructs a path into configName, fsPath, looking up the fsName in the config file (returning NotFoundInConfigFile if not found)

type Retrier

type Retrier interface {
	error
	Retry() bool
}

Retrier is an optional interface for error as to whether the operation should be retried at a high level.

This should be returned from Update or Put methods as required

type SeekOption

type SeekOption struct {
	Offset int64
}

SeekOption defines an HTTP Range option with start only.

func (*SeekOption) Header

func (o *SeekOption) Header() (key string, value string)

Header formats the option as an http header

func (*SeekOption) Mandatory

func (o *SeekOption) Mandatory() bool

Mandatory returns whether the option must be parsed or can be ignored

func (*SeekOption) String

func (o *SeekOption) String() string

String formats the option into human readable form

type SizeSuffix

type SizeSuffix int64

SizeSuffix is parsed by flag with k/M/G suffixes

func (*SizeSuffix) Set

func (x *SizeSuffix) Set(s string) error

Set a SizeSuffix

func (SizeSuffix) String

func (x SizeSuffix) String() string

String turns SizeSuffix into a string

func (*SizeSuffix) Type

func (x *SizeSuffix) Type() string

Type of the value

func (SizeSuffix) Unit

func (x SizeSuffix) Unit(unit string) string

Unit turns SizeSuffix into a string with a unit

type StatsInfo

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

StatsInfo limits and accounts all transfers

func NewStats

func NewStats() *StatsInfo

NewStats cretates an initialised StatsInfo

func (*StatsInfo) Bytes

func (s *StatsInfo) Bytes(bytes int64)

Bytes updates the stats for bytes bytes

func (*StatsInfo) Checking

func (s *StatsInfo) Checking(remote string)

Checking adds a check into the stats

func (*StatsInfo) DoneChecking

func (s *StatsInfo) DoneChecking(remote string)

DoneChecking removes a check from the stats

func (*StatsInfo) DoneTransferring

func (s *StatsInfo) DoneTransferring(remote string, ok bool)

DoneTransferring removes a transfer from the stats

if ok is true then it increments the transfers count

func (*StatsInfo) Error

func (s *StatsInfo) Error()

Error adds a single error into the stats

func (*StatsInfo) Errored

func (s *StatsInfo) Errored() bool

Errored returns whether there have been any errors

func (*StatsInfo) Errors

func (s *StatsInfo) Errors(errors int64)

Errors updates the stats for errors

func (*StatsInfo) GetErrors

func (s *StatsInfo) GetErrors() int64

GetErrors reads the number of errors

func (*StatsInfo) GetTransfers

func (s *StatsInfo) GetTransfers() int64

GetTransfers reads the number of transfers

func (*StatsInfo) Log

func (s *StatsInfo) Log()

Log outputs the StatsInfo to the log

func (*StatsInfo) ResetCounters

func (s *StatsInfo) ResetCounters()

ResetCounters sets the counters (bytes, checks, errors, transfers) to 0

func (*StatsInfo) ResetErrors

func (s *StatsInfo) ResetErrors()

ResetErrors sets the errors count to 0

func (*StatsInfo) String

func (s *StatsInfo) String() string

String convert the StatsInfo to a string for printing

func (*StatsInfo) Transferring

func (s *StatsInfo) Transferring(remote string)

Transferring adds a transfer into the stats

type Transport

type Transport struct {
	*http.Transport
	// contains filtered or unexported fields
}

Transport is a our http Transport which wraps an http.Transport * Sets the User Agent * Does logging

func NewTransport

func NewTransport(transport *http.Transport, logHeader, logBody, logAuth bool) *Transport

NewTransport wraps the http.Transport passed in and logs all roundtrips including the body if logBody is set.

func (*Transport) RoundTrip

func (t *Transport) RoundTrip(req *http.Request) (resp *http.Response, err error)

RoundTrip implements the RoundTripper interface.

type UnWrapper

type UnWrapper interface {
	// UnWrap returns the Fs that this Fs is wrapping
	UnWrap() Fs
}

UnWrapper is an optional interfaces for Fs

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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