rclone: github.com/rclone/rclone/fs/operations Index | Files

package operations

import "github.com/rclone/rclone/fs/operations"

Package operations does generic operations on filesystems and objects

Index

Package Files

dedupe.go lsjson.go multithread.go operations.go rc.go reopen.go

func BackupDir Uses

func BackupDir(fdst fs.Fs, fsrc fs.Fs, srcFileName string) (backupDir fs.Fs, err error)

BackupDir returns the correctly configured --backup-dir

func CanServerSideMove Uses

func CanServerSideMove(fdst fs.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 Uses

func Cat(ctx context.Context, f fs.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 Check Uses

func Check(ctx context.Context, fdst, fsrc fs.Fs, oneway bool) error

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

func CheckDownload Uses

func CheckDownload(ctx context.Context, fdst, fsrc fs.Fs, oneway bool) error

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

func CheckEqualReaders Uses

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 Uses

func CheckFn(ctx context.Context, fdst, fsrc fs.Fs, check checkFn, oneway 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 CheckHashes Uses

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 CheckIdentical Uses

func CheckIdentical(ctx context.Context, dst, src fs.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 CleanUp Uses

func CleanUp(ctx context.Context, f fs.Fs) error

CleanUp removes the trash for the Fs

func CompareOrCopyDest Uses

func CompareOrCopyDest(ctx context.Context, fdst fs.Fs, dst, src fs.Object, CompareOrCopyDest, 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 Uses

func ConfigMaxDepth(recursive bool) int

ConfigMaxDepth returns the depth to use for a recursive or non recursive listing.

func Copy Uses

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 Uses

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 Uses

func CopyURL(ctx context.Context, fdst fs.Fs, dstFileName string, url string, dstFileNameFromURL bool) (dst fs.Object, err error)

CopyURL copies the data from the url to (fdst, dstFileName)

func Count Uses

func Count(ctx context.Context, f fs.Fs) (objects int64, size int64, err error)

Count counts the objects and their sizes in the Fs

Obeys includes and excludes

func Deduplicate Uses

func Deduplicate(ctx context.Context, f fs.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 Uses

func Delete(ctx context.Context, f fs.Fs) error

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

func DeleteFile Uses

func DeleteFile(ctx context.Context, dst fs.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 DeleteFileWithBackupDir Uses

func DeleteFileWithBackupDir(ctx context.Context, dst fs.Object, backupDir fs.Fs) (err error)

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 Uses

func DeleteFiles(ctx context.Context, toBeDeleted fs.ObjectsChan) error

DeleteFiles removes all the files passed in the channel

func DeleteFilesWithBackupDir Uses

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 Uses

func DirMove(ctx context.Context, f fs.Fs, srcRemote, dstRemote string) (err error)

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 Uses

func Equal(ctx context.Context, src fs.ObjectInfo, dst fs.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 GetCompareDest Uses

func GetCompareDest() (CompareDest fs.Fs, err error)

GetCompareDest sets up --compare-dest

func GetCopyDest Uses

func GetCopyDest(fdst fs.Fs) (CopyDest fs.Fs, err error)

GetCopyDest sets up --copy-dest

func HashLister Uses

func HashLister(ctx context.Context, ht hash.Type, f fs.Fs, w io.Writer) error

HashLister does a md5sum equivalent for the hash type passed in

func List Uses

func List(ctx context.Context, f fs.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 Uses

func ListDir(ctx context.Context, f fs.Fs, w io.Writer) error

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

func ListFn Uses

func ListFn(ctx context.Context, f fs.Fs, fn func(fs.Object)) error

ListFn lists the Fs to the supplied function

Lists in parallel which may get them out of order

func ListJSON Uses

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 Uses

func ListLong(ctx context.Context, f fs.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 Md5sum Uses

func Md5sum(ctx context.Context, f fs.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 Mkdir Uses

func Mkdir(ctx context.Context, f fs.Fs, dir string) error

Mkdir makes a destination directory or container

func Move Uses

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 Uses

func MoveBackupDir(ctx context.Context, backupDir fs.Fs, dst fs.Object) (err error)

MoveBackupDir moves a file to the backup dir

func MoveFile Uses

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 Uses

func NeedTransfer(ctx context.Context, dst, src fs.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 Overlapping Uses

func Overlapping(fdst, fsrc fs.Info) bool

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

func PublicLink(ctx context.Context, f fs.Fs, remote string) (string, error)

PublicLink adds a "readable by anyone with link" permission on the given file or folder.

func Purge Uses

func Purge(ctx context.Context, f fs.Fs, dir string) error

Purge removes a directory and all of its contents

func Rcat Uses

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 Uses

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 Rmdir Uses

func Rmdir(ctx context.Context, f fs.Fs, dir string) error

Rmdir removes a container but not if not empty

func Rmdirs Uses

func Rmdirs(ctx context.Context, f fs.Fs, dir string, leaveRoot bool) error

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

func Same Uses

func Same(fdst, fsrc fs.Info) bool

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

func SameConfig Uses

func SameConfig(fdst, fsrc fs.Info) bool

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

func SameDir Uses

func SameDir(fdst, fsrc fs.Info) bool

SameDir returns true if fdst and fsrc point to the same underlying Fs and they are the same directory.

func SameObject Uses

func SameObject(src, dst fs.Object) bool

SameObject returns true if src and dst could be pointing to the same object.

func SameRemoteType Uses

func SameRemoteType(fdst, fsrc fs.Info) bool

SameRemoteType returns true if fdst and fsrc are the same type

func SetTier Uses

func SetTier(ctx context.Context, fsrc fs.Fs, tier string) error

SetTier changes tier of object in remote

func Sha1sum Uses

func Sha1sum(ctx context.Context, f fs.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 SuffixName Uses

func SuffixName(remote string) string

SuffixName adds the current --suffix to the remote, obeying --suffix-keep-extension if set

func TryRmdir Uses

func TryRmdir(ctx context.Context, f fs.Fs, dir string) error

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

type DeduplicateMode Uses

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
)

Deduplicate modes

func (*DeduplicateMode) Set Uses

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

Set a DeduplicateMode from a string

func (DeduplicateMode) String Uses

func (x DeduplicateMode) String() string

func (*DeduplicateMode) Type Uses

func (x *DeduplicateMode) Type() string

Type of the value

type FsInfo Uses

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

func GetFsInfo Uses

func GetFsInfo(f fs.Fs) *FsInfo

GetFsInfo gets the information (FsInfo) about a given Fs

type ListFormat Uses

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

ListFormat defines files information print format

func (*ListFormat) AddEncrypted Uses

func (l *ListFormat) AddEncrypted()

AddEncrypted adds the encrypted path to file to output

func (*ListFormat) AddHash Uses

func (l *ListFormat) AddHash(ht hash.Type)

AddHash adds the hash of the type given to the output

func (*ListFormat) AddID Uses

func (l *ListFormat) AddID()

AddID adds file's ID to the output if known

func (*ListFormat) AddMimeType Uses

func (l *ListFormat) AddMimeType()

AddMimeType adds file's MimeType to the output if known

func (*ListFormat) AddModTime Uses

func (l *ListFormat) AddModTime()

AddModTime adds file's Mod Time to output

func (*ListFormat) AddOrigID Uses

func (l *ListFormat) AddOrigID()

AddOrigID adds file's Original ID to the output if known

func (*ListFormat) AddPath Uses

func (l *ListFormat) AddPath()

AddPath adds path to file to output

func (*ListFormat) AddSize Uses

func (l *ListFormat) AddSize()

AddSize adds file's size to output

func (*ListFormat) AddTier Uses

func (l *ListFormat) AddTier()

AddTier adds file's Tier to the output if known

func (*ListFormat) AppendOutput Uses

func (l *ListFormat) AppendOutput(functionToAppend func(item *ListJSONItem) string)

AppendOutput adds string generated by specific function to printed output

func (*ListFormat) Format Uses

func (l *ListFormat) Format(entry *ListJSONItem) (result string)

Format prints information about the DirEntry in the format defined

func (*ListFormat) SetAbsolute Uses

func (l *ListFormat) SetAbsolute(absolute bool)

SetAbsolute prints a leading slash in front of path names

func (*ListFormat) SetCSV Uses

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 Uses

func (l *ListFormat) SetDirSlash(dirSlash bool)

SetDirSlash defines if slash should be printed

func (*ListFormat) SetOutput Uses

func (l *ListFormat) SetOutput(output []func(entry *ListJSONItem) string)

SetOutput sets functions used to create files information

func (*ListFormat) SetSeparator Uses

func (l *ListFormat) SetSeparator(separator string)

SetSeparator changes separator in struct

type ListJSONItem Uses

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

type ListJSONOpt Uses

type ListJSONOpt struct {
    Recurse       bool `json:"recurse"`
    NoModTime     bool `json:"noModTime"`
    ShowEncrypted bool `json:"showEncrypted"`
    ShowOrigIDs   bool `json:"showOrigIDs"`
    ShowHash      bool `json:"showHash"`
    DirsOnly      bool `json:"dirsOnly"`
    FilesOnly     bool `json:"filesOnly"`
}

ListJSONOpt describes the options for ListJSON

type Timestamp Uses

type Timestamp struct {
    When   time.Time
    Format string
}

Timestamp a time in the provided format

func (Timestamp) MarshalJSON Uses

func (t Timestamp) MarshalJSON() (out []byte, err error)

MarshalJSON turns a Timestamp into JSON

Package operations imports 32 packages (graph) and is imported by 155 packages. Updated 2019-10-17. Refresh now. Tools for package owners.