Documentation ¶
Overview ¶
Package operations does generic operations on filesystems and objects
Index ¶
- Variables
- func BackupDir(ctx context.Context, fdst fs.Fs, fsrc fs.Fs, srcFileName string) (backupDir fs.Fs, err error)
- func CanServerSideMove(fdst fs.Fs) bool
- func Cat(ctx context.Context, f fs.Fs, w io.Writer, offset, count int64) error
- func Check(ctx context.Context, opt *CheckOpt) error
- func CheckDownload(ctx context.Context, opt *CheckOpt) error
- func CheckEqualReaders(in1, in2 io.Reader) (differ bool, err error)
- func CheckFn(ctx context.Context, opt *CheckOpt) error
- func CheckHashes(ctx context.Context, src fs.ObjectInfo, dst fs.Object) (equal bool, ht hash.Type, err error)
- func CheckIdenticalDownload(ctx context.Context, dst, src fs.Object) (differ bool, err error)
- func CheckSum(ctx context.Context, fsrc, fsum fs.Fs, sumFile string, hashType hash.Type, ...) error
- func CleanUp(ctx context.Context, f fs.Fs) error
- func CommonHash(ctx context.Context, fa, fb fs.Info) (hash.Type, *fs.HashesOption)
- func CompareOrCopyDest(ctx context.Context, fdst fs.Fs, dst, src fs.Object, CompareOrCopyDest []fs.Fs, ...) (NoNeedTransfer bool, err error)
- func ConfigMaxDepth(ctx context.Context, recursive bool) int
- func Copy(ctx context.Context, f fs.Fs, dst fs.Object, remote string, src fs.Object) (newDst fs.Object, err error)
- func CopyFile(ctx context.Context, fdst fs.Fs, fsrc fs.Fs, dstFileName string, ...) (err error)
- func CopyURL(ctx context.Context, fdst fs.Fs, dstFileName string, url string, ...) (dst fs.Object, err error)
- func CopyURLToWriter(ctx context.Context, url string, out io.Writer) (err error)
- func Count(ctx context.Context, f fs.Fs) (objects int64, size int64, err error)
- func CountString(count int64, humanReadable bool) string
- func CountStringField(count int64, humanReadable bool, rawWidth int) string
- func Deduplicate(ctx context.Context, f fs.Fs, mode DeduplicateMode, byHash bool) error
- func Delete(ctx context.Context, f fs.Fs) error
- func DeleteFile(ctx context.Context, dst fs.Object) (err error)
- func DeleteFileWithBackupDir(ctx context.Context, dst fs.Object, backupDir fs.Fs) (err error)
- func DeleteFiles(ctx context.Context, toBeDeleted fs.ObjectsChan) error
- func DeleteFilesWithBackupDir(ctx context.Context, toBeDeleted fs.ObjectsChan, backupDir fs.Fs) error
- func DirMove(ctx context.Context, f fs.Fs, srcRemote, dstRemote string) (err error)
- func Equal(ctx context.Context, src fs.ObjectInfo, dst fs.Object) bool
- func GetCompareDest(ctx context.Context) (CompareDest []fs.Fs, err error)
- func GetCopyDest(ctx context.Context, fdst fs.Fs) (CopyDest []fs.Fs, err error)
- func HashLister(ctx context.Context, ht hash.Type, outputBase64 bool, downloadFlag bool, ...) error
- func HashSumStream(ht hash.Type, outputBase64 bool, in io.ReadCloser, w io.Writer) error
- func List(ctx context.Context, f fs.Fs, w io.Writer) error
- func ListDir(ctx context.Context, f fs.Fs, w io.Writer) error
- func ListFn(ctx context.Context, f fs.Fs, fn func(fs.Object)) error
- func ListJSON(ctx context.Context, fsrc fs.Fs, remote string, opt *ListJSONOpt, ...) error
- func ListLong(ctx context.Context, f fs.Fs, w io.Writer) error
- func Mkdir(ctx context.Context, f fs.Fs, dir string) error
- func Move(ctx context.Context, fdst fs.Fs, dst fs.Object, remote string, src fs.Object) (newDst fs.Object, err error)
- func MoveBackupDir(ctx context.Context, backupDir fs.Fs, dst fs.Object) (err error)
- func MoveFile(ctx context.Context, fdst fs.Fs, fsrc fs.Fs, dstFileName string, ...) (err error)
- func NeedTransfer(ctx context.Context, dst, src fs.Object) bool
- func NewReOpen(ctx context.Context, src fs.Object, maxTries int, options ...fs.OpenOption) (rc io.ReadCloser, err error)
- func Overlapping(fdst, fsrc fs.Info) bool
- func PublicLink(ctx context.Context, f fs.Fs, remote string, expire fs.Duration, unlink bool) (string, error)
- func Purge(ctx context.Context, f fs.Fs, dir string) (err error)
- func Rcat(ctx context.Context, fdst fs.Fs, dstFileName string, in io.ReadCloser, ...) (dst fs.Object, err error)
- func RcatSize(ctx context.Context, fdst fs.Fs, dstFileName string, in io.ReadCloser, ...) (dst fs.Object, err error)
- func Retry(ctx context.Context, o interface{}, maxTries int, fn func() error) (err error)
- func Rmdir(ctx context.Context, f fs.Fs, dir string) error
- func Rmdirs(ctx context.Context, f fs.Fs, dir string, leaveRoot bool) error
- func Same(fdst, fsrc fs.Info) bool
- func SameConfig(fdst, fsrc fs.Info) bool
- func SameConfigArr(fdst fs.Info, fsrcs []fs.Fs) bool
- func SameDir(fdst, fsrc fs.Info) bool
- func SameObject(src, dst fs.Object) bool
- func SameRemoteType(fdst, fsrc fs.Info) bool
- func SetTier(ctx context.Context, fsrc fs.Fs, tier string) error
- func SizeString(size int64, humanReadable bool) string
- func SizeStringField(size int64, humanReadable bool, rawWidth int) string
- func SkipDestructive(ctx context.Context, subject interface{}, action string) (skip bool)
- func SuffixName(ctx context.Context, remote string) string
- func TouchDir(ctx context.Context, f fs.Fs, remote string, t time.Time, recursive bool) error
- func TryRmdir(ctx context.Context, f fs.Fs, dir string) error
- type CheckOpt
- type DeduplicateMode
- type FsInfo
- type HashSums
- type ListFormat
- func (l *ListFormat) AddEncrypted()
- func (l *ListFormat) AddHash(ht hash.Type)
- func (l *ListFormat) AddID()
- func (l *ListFormat) AddMimeType()
- func (l *ListFormat) AddModTime()
- func (l *ListFormat) AddOrigID()
- func (l *ListFormat) AddPath()
- func (l *ListFormat) AddSize()
- func (l *ListFormat) AddTier()
- func (l *ListFormat) AppendOutput(functionToAppend func(item *ListJSONItem) string)
- func (l *ListFormat) Format(entry *ListJSONItem) (result string)
- func (l *ListFormat) SetAbsolute(absolute bool)
- func (l *ListFormat) SetCSV(useCSV bool)
- func (l *ListFormat) SetDirSlash(dirSlash bool)
- func (l *ListFormat) SetOutput(output []func(entry *ListJSONItem) string)
- func (l *ListFormat) SetSeparator(separator string)
- type ListJSONItem
- type ListJSONOpt
- type OverrideRemote
- type ReOpen
- type Timestamp
Constants ¶
This section is empty.
Variables ¶
var SyncPrintf = func(format string, a ...interface{}) { fmt.Printf(format, a...) }
SyncPrintf is a global var holding the Printf function used in syncFprintf so that it can be overridden Note, despite name, does not provide sync and should not be called directly Call syncFprintf, which provides sync
Functions ¶
func BackupDir ¶ added in v1.6.1
func BackupDir(ctx context.Context, fdst fs.Fs, fsrc fs.Fs, srcFileName string) (backupDir fs.Fs, err error)
BackupDir returns the correctly configured --backup-dir
func CanServerSideMove ¶
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 ¶
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 CheckDownload ¶
CheckDownload checks the files in fsrc and fdst according to Size and the actual contents of the files.
func CheckEqualReaders ¶
CheckEqualReaders checks to see if in1 and in2 have the same content when read.
it returns true if differences were found
func CheckFn ¶
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 CheckHashes ¶
func CheckHashes(ctx context.Context, src fs.ObjectInfo, dst fs.Object) (equal bool, ht hash.Type, 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 CheckIdenticalDownload ¶ added in v1.50.20
CheckIdenticalDownload checks to see if dst and src are identical by reading all their bytes if necessary.
it returns true if differences were found
func CheckSum ¶ added in v1.56.0
func CheckSum(ctx context.Context, fsrc, fsum fs.Fs, sumFile string, hashType hash.Type, opt *CheckOpt, download bool) error
CheckSum checks filesystem hashes against a SUM file
func CommonHash ¶ added in v1.50.4
CommonHash returns a single hash.Type and a HashOption with that type which is in common between the two fs.Fs.
func CompareOrCopyDest ¶ added in v1.6.1
func CompareOrCopyDest(ctx context.Context, fdst fs.Fs, dst, src fs.Object, CompareOrCopyDest []fs.Fs, backupDir fs.Fs) (NoNeedTransfer bool, err error)
CompareOrCopyDest checks --compare-dest and --copy-dest to see if src does not need to be copied
Returns True if src does not need to be copied
func ConfigMaxDepth ¶
ConfigMaxDepth returns the depth to use for a recursive or non recursive listing.
func Copy ¶
func Copy(ctx context.Context, f fs.Fs, dst fs.Object, remote string, src fs.Object) (newDst fs.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.
It returns the destination object if possible. Note that this may be nil.
func CopyFile ¶
func CopyFile(ctx context.Context, fdst fs.Fs, fsrc fs.Fs, dstFileName string, srcFileName string) (err error)
CopyFile moves a single file possibly to a new name
func CopyURL ¶
func CopyURL(ctx context.Context, fdst fs.Fs, dstFileName string, url string, dstFileNameFromURL bool, noClobber bool) (dst fs.Object, err error)
CopyURL copies the data from the url to (fdst, dstFileName)
func CopyURLToWriter ¶ added in v1.50.4
CopyURLToWriter copies the data from the url to the io.Writer supplied
func CountString ¶ added in v1.56.0
CountString make string representation of count for output
Optional human-readable format including a decimal suffix
func CountStringField ¶ added in v1.56.0
CountStringField make string representation of count for output in fixed width field
Similar to SizeStringField, but human readable with decimal prefix and field width 8 since there is no 'i' in the decimal prefix symbols (e.g. "999.999E")
func Deduplicate ¶
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 ¶
Delete removes all the contents of a container. Unlike Purge, it obeys includes and excludes.
func DeleteFile ¶
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 DeleteFileWithBackupDir ¶
DeleteFileWithBackupDir deletes a single file respecting --dry-run and accumulating stats and errors.
If backupDir is set then it moves the file to there instead of deleting
func DeleteFiles ¶
func DeleteFiles(ctx context.Context, toBeDeleted fs.ObjectsChan) error
DeleteFiles removes all the files passed in the channel
func DeleteFilesWithBackupDir ¶
func DeleteFilesWithBackupDir(ctx context.Context, toBeDeleted fs.ObjectsChan, backupDir fs.Fs) error
DeleteFilesWithBackupDir removes all the files passed in the channel
If backupDir is set the files will be placed into that directory instead of being deleted.
func DirMove ¶
DirMove renames srcRemote to dstRemote
It does this by loading the directory tree into memory (using ListR if available) and doing renames in parallel.
func Equal ¶
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 GetCompareDest ¶ added in v1.6.1
GetCompareDest sets up --compare-dest
func GetCopyDest ¶ added in v1.6.1
GetCopyDest sets up --copy-dest
func HashLister ¶
func HashLister(ctx context.Context, ht hash.Type, outputBase64 bool, downloadFlag bool, f fs.Fs, w io.Writer) error
HashLister does an md5sum equivalent for the hash type passed in Updated to handle both standard hex encoding and base64 Updated to perform multiple hashes concurrently
func HashSumStream ¶ added in v1.57.1
HashSumStream outputs a line compatible with md5sum to w based on the input stream in and the hash type ht passed in. If outputBase64 is set then the hash will be base64 instead of hexadecimal.
func List ¶
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 ListFn ¶
ListFn lists the Fs to the supplied function
Lists in parallel which may get them out of order
func ListJSON ¶
func ListJSON(ctx context.Context, fsrc fs.Fs, remote string, opt *ListJSONOpt, callback func(*ListJSONItem) error) error
ListJSON lists fsrc using the options in opt calling callback for each item
func ListLong ¶
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 Move ¶
func Move(ctx context.Context, fdst fs.Fs, dst fs.Object, remote string, src fs.Object) (newDst fs.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.
Note that you must check the destination does not exist before calling this and pass it as dst. If you pass dst=nil and the destination does exist then this may create duplicates or return errors.
It returns the destination object if possible. Note that this may be nil.
func MoveBackupDir ¶ added in v1.6.1
MoveBackupDir moves a file to the backup dir
func MoveFile ¶
func MoveFile(ctx context.Context, fdst fs.Fs, fsrc fs.Fs, dstFileName string, srcFileName string) (err error)
MoveFile moves a single file possibly to a new name
func NeedTransfer ¶
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 NewReOpen ¶ added in v1.50.20
func NewReOpen(ctx context.Context, src fs.Object, maxTries int, options ...fs.OpenOption) (rc io.ReadCloser, err error)
NewReOpen makes a handle which will reopen itself and seek to where it was on errors
If hashOption is set this will be applied when reading from the start ¶
If rangeOption is set then this will applied when reading from the start, and updated on retries.
func Overlapping ¶
Overlapping returns true if fdst and fsrc point to the same underlying Fs and they overlap.
func PublicLink ¶
func PublicLink(ctx context.Context, f fs.Fs, remote string, expire fs.Duration, unlink bool) (string, error)
PublicLink adds a "readable by anyone with link" permission on the given file or folder.
func Rcat ¶
func Rcat(ctx context.Context, fdst fs.Fs, dstFileName string, in io.ReadCloser, modTime time.Time) (dst fs.Object, err error)
Rcat reads data from the Reader until EOF and uploads it to a file on remote
func RcatSize ¶
func RcatSize(ctx context.Context, fdst fs.Fs, dstFileName string, in io.ReadCloser, size int64, modTime time.Time) (dst fs.Object, err error)
RcatSize reads data from the Reader until EOF and uploads it to a file on remote. Pass in size >=0 if known, <0 if not known
func Rmdirs ¶
Rmdirs removes any empty directories (or directories only containing empty directories) under f, including f.
Rmdirs obeys the filters
func SameConfig ¶
SameConfig returns true if fdst and fsrc are using the same config file entry
func SameConfigArr ¶ added in v1.55.0
SameConfigArr returns true if any of []fsrcs has same config file entry with fdst
func SameDir ¶ added in v1.6.1
SameDir returns true if fdst and fsrc point to the same underlying Fs and they are the same directory.
func SameObject ¶ added in v1.6.1
SameObject returns true if src and dst could be pointing to the same object.
func SameRemoteType ¶
SameRemoteType returns true if fdst and fsrc are the same type
func SizeString ¶ added in v1.56.0
SizeString make string representation of size for output
Optional human-readable format including a binary suffix
func SizeStringField ¶ added in v1.56.0
SizeStringField make string representation of size for output in fixed width field
Optional human-readable format including a binary suffix Argument rawWidth is used to format field with of raw value. When humanReadable option the width is hard coded to 9, since SizeSuffix strings have precision 3 and longest value will be "999.999Ei". This way the width can be optimized depending to the humanReadable option. To always use a longer width the return value can always be fed into another format string with a specific field with.
func SkipDestructive ¶ added in v1.50.20
SkipDestructive should be called whenever rclone is about to do an destructive operation.
It will check the --dry-run flag and it will ask the user if the --interactive flag is set.
subject should be the object or directory in use
action should be a descriptive word or short phrase
Together they should make sense in this sentence: "Rclone is about to action subject".
func SuffixName ¶
SuffixName adds the current --suffix to the remote, obeying --suffix-keep-extension if set
Types ¶
type CheckOpt ¶ added in v1.50.20
type CheckOpt struct {
Fdst, Fsrc fs.Fs // fses to check
Check checkFn // function to use for checking
OneWay bool // one way only?
Combined io.Writer // a file with file names with leading sigils
MissingOnSrc io.Writer // files only in the destination
MissingOnDst io.Writer // files only in the source
Match io.Writer // matching files
Differ io.Writer // differing files
Error io.Writer // files with errors of some kind
}
CheckOpt contains options for the Check functions
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 DeduplicateLargest // choose the largest object DeduplicateSmallest // choose the smallest object DeduplicateList // list duplicates only )
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
type FsInfo ¶ added in v1.6.1
type FsInfo struct { // 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 in Nanoseconds Precision time.Duration // Returns the supported hash types of the filesystem Hashes []string // Features returns the optional features of this Fs Features map[string]bool }
FsInfo provides information about a remote
type ListFormat ¶
type ListFormat struct {
// contains filtered or unexported fields
}
ListFormat defines files information print format
func (*ListFormat) AddEncrypted ¶
func (l *ListFormat) AddEncrypted()
AddEncrypted adds the encrypted path to file to output
func (*ListFormat) AddHash ¶
func (l *ListFormat) AddHash(ht hash.Type)
AddHash adds the hash of the type given to the output
func (*ListFormat) AddMimeType ¶
func (l *ListFormat) AddMimeType()
AddMimeType adds file's MimeType to the output if known
func (*ListFormat) AddModTime ¶
func (l *ListFormat) AddModTime()
AddModTime adds file's Mod Time to output
func (*ListFormat) AddOrigID ¶
func (l *ListFormat) AddOrigID()
AddOrigID adds file's Original ID to the output if known
func (*ListFormat) AddTier ¶
func (l *ListFormat) AddTier()
AddTier adds file's Tier to the output if known
func (*ListFormat) AppendOutput ¶
func (l *ListFormat) AppendOutput(functionToAppend func(item *ListJSONItem) string)
AppendOutput adds string generated by specific function to printed output
func (*ListFormat) Format ¶
func (l *ListFormat) Format(entry *ListJSONItem) (result string)
Format prints information about the DirEntry in the format defined
func (*ListFormat) SetAbsolute ¶
func (l *ListFormat) SetAbsolute(absolute bool)
SetAbsolute prints a leading slash in front of path names
func (*ListFormat) SetCSV ¶
func (l *ListFormat) SetCSV(useCSV bool)
SetCSV defines if the output should be csv
Note that you should call SetSeparator before this if you want a custom separator
func (*ListFormat) SetDirSlash ¶
func (l *ListFormat) SetDirSlash(dirSlash bool)
SetDirSlash defines if slash should be printed
func (*ListFormat) SetOutput ¶
func (l *ListFormat) SetOutput(output []func(entry *ListJSONItem) string)
SetOutput sets functions used to create files information
func (*ListFormat) SetSeparator ¶
func (l *ListFormat) SetSeparator(separator string)
SetSeparator changes separator in struct
type ListJSONItem ¶
type ListJSONItem struct { Path string Name string EncryptedPath string `json:",omitempty"` Encrypted string `json:",omitempty"` Size int64 MimeType string `json:",omitempty"` ModTime Timestamp //`json:",omitempty"` IsDir bool Hashes map[string]string `json:",omitempty"` ID string `json:",omitempty"` OrigID string `json:",omitempty"` Tier string `json:",omitempty"` IsBucket bool `json:",omitempty"` }
ListJSONItem in the struct which gets marshalled for each line
func StatJSON ¶ added in v1.57.1
func StatJSON(ctx context.Context, fsrc fs.Fs, remote string, opt *ListJSONOpt) (item *ListJSONItem, err error)
StatJSON returns a single JSON stat entry for the fsrc, remote path
The item returned may be nil if it is not found or excluded with DirsOnly/FilesOnly
type ListJSONOpt ¶
type ListJSONOpt struct { Recurse bool `json:"recurse"` NoModTime bool `json:"noModTime"` NoMimeType bool `json:"noMimeType"` ShowEncrypted bool `json:"showEncrypted"` ShowOrigIDs bool `json:"showOrigIDs"` ShowHash bool `json:"showHash"` DirsOnly bool `json:"dirsOnly"` FilesOnly bool `json:"filesOnly"` HashTypes []string `json:"hashTypes"` // hash types to show if ShowHash is set, e.g. "MD5", "SHA-1" }
ListJSONOpt describes the options for ListJSON
type OverrideRemote ¶ added in v1.50.4
type OverrideRemote struct { fs.ObjectInfo // contains filtered or unexported fields }
OverrideRemote is a wrapper to override the Remote for an ObjectInfo
func NewOverrideRemote ¶ added in v1.50.4
func NewOverrideRemote(oi fs.ObjectInfo, remote string) *OverrideRemote
NewOverrideRemote returns an OverrideRemoteObject which will return the remote specified
func (*OverrideRemote) GetTier ¶ added in v1.50.4
func (o *OverrideRemote) GetTier() string
GetTier returns storage tier or class of the Object
func (*OverrideRemote) ID ¶ added in v1.50.4
func (o *OverrideRemote) ID() string
ID returns the ID of the Object if known, or "" if not
func (*OverrideRemote) MimeType ¶ added in v1.50.4
func (o *OverrideRemote) MimeType(ctx context.Context) string
MimeType returns the mime type of the underlying object or "" if it can't be worked out
func (*OverrideRemote) Remote ¶ added in v1.50.4
func (o *OverrideRemote) Remote() string
Remote returns the overridden remote name
func (*OverrideRemote) UnWrap ¶ added in v1.50.4
func (o *OverrideRemote) UnWrap() fs.Object
UnWrap returns the Object that this Object is wrapping or nil if it isn't wrapping anything