Skip to content

"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files

vfs: remove un-needed (after introduction of rcat) createInfo struct

Nick Craig-Wooda0cfa0929b58
diff --git a/vfs/createinfo.go b/vfs/createinfo.go
deleted file mode 100644
index 155a91b64..000000000
--- a/vfs/createinfo.go
+++ /dev/null
@@ -1,60 +0,0 @@
-package vfs
-
-import (
- "time"
-
- "github.com/ncw/rclone/fs"
-)
-
-// info to create a new object
-type createInfo struct {
- f fs.Fs
- remote string
-}
-
-func newCreateInfo(f fs.Fs, remote string) *createInfo {
- return &createInfo{
- f: f,
- remote: remote,
- }
-}
-
-// Fs returns read only access to the Fs that this object is part of
-func (ci *createInfo) Fs() fs.Info {
- return ci.f
-}
-
-// String returns the remote path
-func (ci *createInfo) String() string {
- return ci.remote
-}
-
-// Remote returns the remote path
-func (ci *createInfo) Remote() string {
- return ci.remote
-}
-
-// Hash returns the selected checksum of the file
-// If no checksum is available it returns ""
-func (ci *createInfo) Hash(fs.HashType) (string, error) {
- return "", fs.ErrHashUnsupported
-}
-
-// ModTime returns the modification date of the file
-// It should return a best guess if one isn't available
-func (ci *createInfo) ModTime() time.Time {
- return time.Now()
-}
-
-// Size returns the size of the file
-func (ci *createInfo) Size() int64 {
- // FIXME this means this won't work with all remotes...
- return 0
-}
-
-// Storable says whether this object can be stored
-func (ci *createInfo) Storable() bool {
- return true
-}
-
-var _ fs.ObjectInfo = (*createInfo)(nil)
diff --git a/vfs/createinfo_test.go b/vfs/createinfo_test.go
deleted file mode 100644
index 240015164..000000000
--- a/vfs/createinfo_test.go
+++ /dev/null
@@ -1,29 +0,0 @@
-package vfs
-
-import (
- "testing"
- "time"
-
- "github.com/ncw/rclone/fs"
- "github.com/ncw/rclone/fstest"
- "github.com/stretchr/testify/assert"
-)
-
-func TestCreateInfo(t *testing.T) {
- r := fstest.NewRun(t)
- defer r.Finalise()
-
- remote := "file/to/be/created"
- ci := newCreateInfo(r.Fremote, remote)
-
- // Test methods
- assert.Equal(t, r.Fremote, ci.Fs())
- assert.Equal(t, remote, ci.String())
- assert.Equal(t, remote, ci.Remote())
- _, err := ci.Hash(fs.HashMD5)
- assert.Equal(t, fs.ErrHashUnsupported, err)
- assert.WithinDuration(t, time.Now(), ci.ModTime(), time.Second)
- assert.Equal(t, int64(0), ci.Size())
- assert.Equal(t, true, ci.Storable())
-
-}
diff --git a/vfs/file.go b/vfs/file.go
index 70fb8da67..75ac1073b 100644
--- a/vfs/file.go
+++ b/vfs/file.go
@@ -235,8 +235,7 @@ func (f *File) OpenWrite() (fh *WriteFileHandle, err error) {
}
// fs.Debugf(o, "File.OpenWrite")
- src := newCreateInfo(f.d.f, f.path())
- fh, err = newWriteFileHandle(f.d, f, src)
+ fh, err = newWriteFileHandle(f.d, f, f.path())
err = errors.Wrap(err, "open for write")
if err != nil {
diff --git a/vfs/write.go b/vfs/write.go
index b3a955511..fd61fc856 100644
--- a/vfs/write.go
+++ b/vfs/write.go
@@ -30,9 +30,9 @@ var (
_ io.Closer = (*WriteFileHandle)(nil)
)
-func newWriteFileHandle(d *Dir, f *File, src fs.ObjectInfo) (*WriteFileHandle, error) {
+func newWriteFileHandle(d *Dir, f *File, remote string) (*WriteFileHandle, error) {
fh := &WriteFileHandle{
- remote: src.Remote(),
+ remote: remote,
result: make(chan error, 1),
file: f,
}
@@ -40,7 +40,7 @@ func newWriteFileHandle(d *Dir, f *File, src fs.ObjectInfo) (*WriteFileHandle, e
pipeReader, fh.pipeWriter = io.Pipe()
go func() {
// NB Rcat deals with Stats.Transferring etc
- o, err := fs.Rcat(d.f, src.Remote(), pipeReader, time.Now())
+ o, err := fs.Rcat(d.f, remote, pipeReader, time.Now())
if err != nil {
fs.Errorf(fh.remote, "WriteFileHandle.New Rcat failed: %v", err)
}