Documentation ¶
Overview ¶
Package operations does generic operations on filesystems and objects
Index ¶
- func CanServerSideMove(fdst fs.Fs) bool
- func Cat(f fs.Fs, w io.Writer, offset, count int64) error
- func Check(fdst, fsrc fs.Fs, oneway bool) error
- func CheckDownload(fdst, fsrc fs.Fs, oneway bool) error
- func CheckEqualReaders(in1, in2 io.Reader) (differ bool, err error)
- func CheckFn(fdst, fsrc fs.Fs, check checkFn, oneway bool) error
- func CheckHashes(src fs.ObjectInfo, dst fs.Object) (equal bool, ht hash.Type, err error)
- func CheckIdentical(dst, src fs.Object) (differ bool, err error)
- func CleanUp(f fs.Fs) error
- func ConfigMaxDepth(recursive bool) int
- func Copy(f fs.Fs, dst fs.Object, remote string, src fs.Object) (newDst fs.Object, err error)
- func CopyFile(fdst fs.Fs, fsrc fs.Fs, dstFileName string, srcFileName string) (err error)
- func Count(f fs.Fs) (objects int64, size int64, err error)
- func Deduplicate(f fs.Fs, mode DeduplicateMode) error
- func Delete(f fs.Fs) error
- func DeleteFile(dst fs.Object) (err error)
- func DeleteFileWithBackupDir(dst fs.Object, backupDir fs.Fs) (err error)
- func DeleteFiles(toBeDeleted fs.ObjectsChan) error
- func DeleteFilesWithBackupDir(toBeDeleted fs.ObjectsChan, backupDir fs.Fs) error
- func DropboxHashSum(f fs.Fs, w io.Writer) error
- func Equal(src fs.ObjectInfo, dst fs.Object) bool
- func HashLister(ht hash.Type, f fs.Fs, w io.Writer) error
- func List(f fs.Fs, w io.Writer) error
- func ListDir(f fs.Fs, w io.Writer) error
- func ListFn(f fs.Fs, fn func(fs.Object)) error
- func ListLong(f fs.Fs, w io.Writer) error
- func Md5sum(f fs.Fs, w io.Writer) error
- func Mkdir(f fs.Fs, dir string) error
- func Move(fdst fs.Fs, dst fs.Object, remote string, src fs.Object) (newDst fs.Object, err error)
- func MoveFile(fdst fs.Fs, fsrc fs.Fs, dstFileName string, srcFileName string) (err error)
- func NeedTransfer(dst, src fs.Object) bool
- func Overlapping(fdst, fsrc fs.Info) bool
- func PublicLink(f fs.Fs, remote string) (string, error)
- func Purge(f fs.Fs, dir string) error
- func Rcat(fdst fs.Fs, dstFileName string, in io.ReadCloser, modTime time.Time) (dst fs.Object, err error)
- func RcatSize(fdst fs.Fs, dstFileName string, in io.ReadCloser, size int64, ...) (dst fs.Object, err error)
- func Rmdir(f fs.Fs, dir string) error
- func Rmdirs(f fs.Fs, dir string, leaveRoot bool) error
- func Same(fdst, fsrc fs.Info) bool
- func SameConfig(fdst, fsrc fs.Info) bool
- func Sha1sum(f fs.Fs, w io.Writer) error
- func TryRmdir(f fs.Fs, dir string) error
- type DeduplicateMode
- type ListFormat
- func (l *ListFormat) AddHash(ht hash.Type)
- func (l *ListFormat) AddID()
- func (l *ListFormat) AddMimeType()
- func (l *ListFormat) AddModTime()
- func (l *ListFormat) AddPath()
- func (l *ListFormat) AddSize()
- func (l *ListFormat) AppendOutput(functionToAppend func() string)
- func (l *ListFormat) Format(entry fs.DirEntry) (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() string)
- func (l *ListFormat) SetSeparator(separator string)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
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 ¶
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 ¶
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 ConfigMaxDepth ¶
ConfigMaxDepth returns the depth to use for a recursive or non recursive listing.
func Copy ¶
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 Deduplicate ¶
func Deduplicate(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 ¶
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(toBeDeleted fs.ObjectsChan) error
DeleteFiles removes all the files passed in the channel
func DeleteFilesWithBackupDir ¶
func DeleteFilesWithBackupDir(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 DropboxHashSum ¶
DropboxHashSum list the Fs to the supplied writer
Obeys includes and excludes ¶
Lists in parallel which may get them out of order
func Equal ¶
func Equal(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 HashLister ¶
HashLister does a md5sum equivalent for the hash type passed in
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 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 Md5sum ¶
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 Move ¶
Move src object to dst or fdst 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 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 Overlapping ¶
Overlapping returns true if fdst and fsrc point to the same underlying Fs and they overlap.
func PublicLink ¶
PublicLink adds a "readable by anyone with link" permission on the given file or folder.
func Rcat ¶
func Rcat(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(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.
func SameConfig ¶
SameConfig returns true if fdst and fsrc are using the same config file entry
Types ¶
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 )
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 ListFormat ¶
type ListFormat struct {
// contains filtered or unexported fields
}
ListFormat defines files information print format
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) AppendOutput ¶
func (l *ListFormat) AppendOutput(functionToAppend func() string)
AppendOutput adds string generated by specific function to printed output
func (*ListFormat) Format ¶
func (l *ListFormat) Format(entry fs.DirEntry) (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() string)
SetOutput sets functions used to create files information
func (*ListFormat) SetSeparator ¶
func (l *ListFormat) SetSeparator(separator string)
SetSeparator changes separator in struct