Implement server side copies if possible - fixes #99

Add optional fs.Copier interface

Implemented for
  * swift
  * s3
  * drive
  * dropbox
  * google cloud storage
This commit is contained in:
Nick Craig-Wood
2015-02-14 18:48:08 +00:00
parent fedf81c2b7
commit a96b522958
19 changed files with 355 additions and 40 deletions

View File

@ -24,6 +24,7 @@ var (
fsRegistry []*FsInfo
// Error returned by NewFs if not found in config file
NotFoundInConfigFile = fmt.Errorf("Didn't find section in config file")
ErrorCantCopy = fmt.Errorf("Can't copy object - incompatible remotes")
)
// Filesystem info
@ -149,6 +150,19 @@ type Purger interface {
Purge() error
}
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)
}
// An optional interface for error as to whether the operation should be retried
//
// This should be returned from Update or Put methods as required