diff --git a/drive/drive.go b/drive/drive.go index ebce8fbc6..680e03be3 100644 --- a/drive/drive.go +++ b/drive/drive.go @@ -74,6 +74,7 @@ func init() { // FsDrive represents a remote drive server type FsDrive struct { + name string // name of this remote svc *drive.Service // the connection to the drive server root string // the path we are working on client *http.Client // authorized client @@ -146,6 +147,11 @@ func (m *dirCache) Flush() { // ------------------------------------------------------------ +// The name of the remote (as passed into NewFs) +func (f *FsDrive) Name() string { + return f.name +} + // String converts this FsDrive to a string func (f *FsDrive) String() string { return fmt.Sprintf("Google drive root '%s'", f.root) @@ -332,6 +338,7 @@ func NewFs(name, path string) (fs.Fs, error) { } f := &FsDrive{ + name: name, root: root, dirCache: newDirCache(), pacer: make(chan struct{}, 1), diff --git a/dropbox/dropbox.go b/dropbox/dropbox.go index 077dd6f29..69268962c 100644 --- a/dropbox/dropbox.go +++ b/dropbox/dropbox.go @@ -104,6 +104,7 @@ func configHelper(name string) { // FsDropbox represents a remote dropbox server type FsDropbox struct { + name string // name of this remote db *dropbox.Dropbox // the connection to the dropbox server root string // the path we are working on slashRoot string // root with "/" prefix, lowercase @@ -121,6 +122,11 @@ type FsObjectDropbox struct { // ------------------------------------------------------------ +// The name of the remote (as passed into NewFs) +func (f *FsDropbox) Name() string { + return f.name +} + // String converts this FsDropbox to a string func (f *FsDropbox) String() string { return fmt.Sprintf("Dropbox root '%s'", f.root) @@ -148,7 +154,8 @@ func newDropbox(name string) *dropbox.Dropbox { func NewFs(name, root string) (fs.Fs, error) { db := newDropbox(name) f := &FsDropbox{ - db: db, + name: name, + db: db, } f.setRoot(root) diff --git a/fs/fs.go b/fs/fs.go index 72aab51cf..d93b76b3b 100644 --- a/fs/fs.go +++ b/fs/fs.go @@ -63,6 +63,9 @@ func Register(info *FsInfo) { // A Filesystem, describes the local filesystem and the remote object store type Fs interface { + // The name of the remote (as passed into NewFs) + Name() string + // String returns a description of the FS String() string diff --git a/fs/limited.go b/fs/limited.go index e38ef7e6d..f38c23e14 100644 --- a/fs/limited.go +++ b/fs/limited.go @@ -21,6 +21,11 @@ func NewLimited(fs Fs, objects ...Object) Fs { return f } +// The name of the remote (as passed into NewFs) +func (f *Limited) Name() string { + return f.fs.Name() // return name of underlying remote +} + // String returns a description of the FS func (f *Limited) String() string { return fmt.Sprintf("%s limited to %d objects", f.fs.String(), len(f.objects)) diff --git a/googlecloudstorage/googlecloudstorage.go b/googlecloudstorage/googlecloudstorage.go index a8ce8aef8..128011956 100644 --- a/googlecloudstorage/googlecloudstorage.go +++ b/googlecloudstorage/googlecloudstorage.go @@ -112,6 +112,7 @@ func init() { // FsStorage represents a remote storage server type FsStorage struct { + name string // name of this remote svc *storage.Service // the connection to the storage server client *http.Client // authorized client bucket string // the bucket we are working on @@ -135,6 +136,11 @@ type FsObjectStorage struct { // ------------------------------------------------------------ +// The name of the remote (as passed into NewFs) +func (f *FsStorage) Name() string { + return f.name +} + // String converts this FsStorage to a string func (f *FsStorage) String() string { if f.root == "" { @@ -171,6 +177,7 @@ func NewFs(name, root string) (fs.Fs, error) { } f := &FsStorage{ + name: name, bucket: bucket, root: directory, projectNumber: fs.ConfigFile.MustValue(name, "project_number"), diff --git a/local/local.go b/local/local.go index 50cd7e08f..40992382d 100644 --- a/local/local.go +++ b/local/local.go @@ -33,6 +33,7 @@ func init() { // FsLocal represents a local filesystem rooted at root type FsLocal struct { + name string // the name of the remote root string // The root directory precisionOk sync.Once // Whether we need to read the precision precision time.Duration // precision of local filesystem @@ -54,6 +55,7 @@ type FsObjectLocal struct { func NewFs(name, root string) (fs.Fs, error) { root = filepath.ToSlash(path.Clean(root)) f := &FsLocal{ + name: name, root: root, warned: make(map[string]struct{}), } @@ -70,6 +72,11 @@ func NewFs(name, root string) (fs.Fs, error) { return f, nil } +// The name of the remote (as passed into NewFs) +func (f *FsLocal) Name() string { + return f.name +} + // String converts this FsLocal to a string func (f *FsLocal) String() string { return fmt.Sprintf("Local file system at %s", f.root) diff --git a/s3/s3.go b/s3/s3.go index 1c8316e72..810b6d900 100644 --- a/s3/s3.go +++ b/s3/s3.go @@ -128,6 +128,7 @@ const ( // FsS3 represents a remote s3 server type FsS3 struct { + name string // the name of the remote c *s3.S3 // the connection to the s3 server bucket string // the bucket we are working on perm string // permissions for new buckets / objects @@ -151,6 +152,11 @@ type FsObjectS3 struct { // ------------------------------------------------------------ +// The name of the remote (as passed into NewFs) +func (f *FsS3) Name() string { + return f.name +} + // String converts this FsS3 to a string func (f *FsS3) String() string { if f.root == "" { @@ -235,6 +241,7 @@ func NewFs(name, root string) (fs.Fs, error) { return nil, err } f := &FsS3{ + name: name, c: c, bucket: bucket, // FIXME perm: s3.Private, // FIXME need user to specify diff --git a/swift/swift.go b/swift/swift.go index b9faeb0e3..db01bf9e0 100644 --- a/swift/swift.go +++ b/swift/swift.go @@ -58,6 +58,7 @@ func init() { // FsSwift represents a remote swift server type FsSwift struct { + name string // name of this remote c swift.Connection // the connection to the swift server container string // the container we are working on root string // the path we are working on if any @@ -75,6 +76,11 @@ type FsObjectSwift struct { // ------------------------------------------------------------ +// The name of the remote (as passed into NewFs) +func (f *FsSwift) Name() string { + return f.name +} + // String converts this FsSwift to a string func (f *FsSwift) String() string { if f.root == "" { @@ -141,6 +147,7 @@ func NewFs(name, root string) (fs.Fs, error) { return nil, err } f := &FsSwift{ + name: name, c: *c, container: container, root: directory,