"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files
Go azure-blobazure-blob-storageazure-filesbackblaze-b2cloud-storagedropboxencryptionftpfuse-filesystemgogolanggoogle-cloud-storagegoogle-driveonedriveopenstack-swiftrclones3sftpsyncwebdav
vfs: [bugfix] Implement Name() method in WriteFileHandle and ReadFileHandle
Saleh Dindar23f8dea18209
diff --git a/vfs/read.go b/vfs/read.goindex 17e74ec13..8bedeae91 100644--- a/vfs/read.go+++ b/vfs/read.go@@ -484,6 +484,11 @@ func (fh *ReadFileHandle) Release() error {return err}+// Name returns the name of the file from the underlying Object.+func (fh *ReadFileHandle) Name() string {+ return fh.file.String()+}+// Size returns the size of the underlying filefunc (fh *ReadFileHandle) Size() int64 {fh.mu.Lock()diff --git a/vfs/read_test.go b/vfs/read_test.goindex db8d0f841..6b7d55c4e 100644--- a/vfs/read_test.go+++ b/vfs/read_test.go@@ -44,6 +44,9 @@ func TestReadFileHandleMethods(t *testing.T) {assert.Equal(t, "<nil *ReadFileHandle>", (*ReadFileHandle)(nil).String())assert.Equal(t, "<nil *ReadFileHandle.file>", new(ReadFileHandle).String())+ // Name+ assert.Equal(t, "dir/file1", fh.Name())+// Nodenode := fh.Node()assert.Equal(t, "file1", node.Name())diff --git a/vfs/read_write_test.go b/vfs/read_write_test.goindex 75b930f73..7a49c9ab5 100644--- a/vfs/read_write_test.go+++ b/vfs/read_write_test.go@@ -346,6 +346,9 @@ func TestRWFileHandleWriteAt(t *testing.T) {return n}+ // Name+ assert.Equal(t, "file1", fh.Name())+// Preconditionsassert.Equal(t, int64(0), offset())assert.True(t, fh.opened)diff --git a/vfs/write.go b/vfs/write.goindex b820d8172..2a263af67 100644--- a/vfs/write.go+++ b/vfs/write.go@@ -322,3 +322,8 @@ func (fh *WriteFileHandle) ReadAt(p []byte, off int64) (n int, err error) {func (fh *WriteFileHandle) Sync() error {return nil}++// Name returns the name of the file from the underlying Object.+func (fh *WriteFileHandle) Name() string {+ return fh.file.String()+}diff --git a/vfs/write_test.go b/vfs/write_test.goindex 629628555..77173bdf5 100644--- a/vfs/write_test.go+++ b/vfs/write_test.go@@ -39,6 +39,9 @@ func TestWriteFileHandleReadonly(t *testing.T) {}r, vfs, fh := writeHandleCreate(t)+ // Name+ assert.Equal(t, "file1", fh.Name())+// Write a file, so underlying remote will be created_, err := fh.Write([]byte("hello"))assert.NoError(t, err)