Repository: rclone/rclone
Pull request #7076 (2023-06-23 08:07:57)

Update drive.md
#### What is the purpose of this change?
fix typo

#### Was the change discussed in an issue or in the forum before?

do not know

#### Checklist

- [ ] I have read the [contribution guidelines](https://github.com/rclone/rclone/blob/master/CONTRIBUTING.md#submitting-a-new-feature-or-bug-fix).
- [x] I have added tests for all changes in this PR if appropriate.
- [x] I have added documentation for the changes if appropriate.
- [ ] All commit messages are in [house style](https://github.com/rclone/rclone/blob/master/CONTRIBUTING.md#commit-messages).
- [x] I'm done, this Pull Request is ready for review :-)



Patch:
diff --git a/docs/content/authors.md b/docs/content/authors.md
index 2360f3cf2..0b831a948 100644
--- a/docs/content/authors.md
+++ b/docs/content/authors.md
@@ -729,3 +729,5 @@ put them back in again.` >}}
   * Tareq Sharafy <tareq.sha@gmail.com>
   * kapitainsky <dariuszb@me.com>
   * douchen <playgoobug@gmail.com>
+  * Sam Lai <70988+slai@users.noreply.github.com>
+  * URenko <18209292+URenko@users.noreply.github.com>
diff --git a/docs/content/drive.md b/docs/content/drive.md
index c687315e9..12d9b0545 100644
--- a/docs/content/drive.md
+++ b/docs/content/drive.md
@@ -403,7 +403,7 @@ like a symlink in unix, except they point to the underlying file data
 (e.g. the inode in unix terms) so they don't break if the source is
 renamed or moved about.
 
-Be default rclone treats these as follows.
+By default rclone treats these as follows.
 
 For shortcuts pointing to files:
 
diff --git a/fs/newfs.go b/fs/newfs.go
index 52375e86e..9be890ec7 100644
--- a/fs/newfs.go
+++ b/fs/newfs.go
@@ -115,11 +115,11 @@ func ParseRemote(path string) (fsInfo *RegInfo, configName, fsPath string, conne
 	return fsInfo, configName, fsPath, parsed.Config, err
 }
 
-// ConfigString returns a canonical version of the config string used
+// configString returns a canonical version of the config string used
 // to configure the Fs as passed to fs.NewFs
-func ConfigString(f Fs) string {
+func configString(f Fs, full bool) string {
 	name := f.Name()
-	if open := strings.IndexRune(name, '{'); open >= 0 && strings.HasSuffix(name, "}") {
+	if open := strings.IndexRune(name, '{'); full && open >= 0 && strings.HasSuffix(name, "}") {
 		suffix := name[open:]
 		overriddenConfigMu.Lock()
 		config, ok := overriddenConfig[suffix]
@@ -137,6 +137,21 @@ func ConfigString(f Fs) string {
 	return name + ":" + root
 }
 
+// ConfigString returns a canonical version of the config string used
+// to configure the Fs as passed to fs.NewFs. For Fs with extra
+// parameters this will include a canonical {hexstring} suffix.
+func ConfigString(f Fs) string {
+	return configString(f, false)
+}
+
+// ConfigStringFull returns a canonical version of the config string
+// used to configure the Fs as passed to fs.NewFs. This string can be
+// used to re-instantiate the Fs exactly so includes all the extra
+// parameters passed in.
+func ConfigStringFull(f Fs) string {
+	return configString(f, true)
+}
+
 // TemporaryLocalFs creates a local FS in the OS's temporary directory.
 //
 // No cleanup is performed, the caller must call Purge on the Fs themselves.


Test patch:
diff --git a/backend/s3/s3_internal_test.go b/backend/s3/s3_internal_test.go
index d4b4e1e17..f48045072 100644
--- a/backend/s3/s3_internal_test.go
+++ b/backend/s3/s3_internal_test.go
@@ -318,7 +318,7 @@ func (f *Fs) InternalTestVersions(t *testing.T) {
 
 		// Check we can make a NewFs from that object with a version suffix
 		t.Run("NewFs", func(t *testing.T) {
-			newPath := bucket.Join(fs.ConfigString(f), fileNameVersion)
+			newPath := bucket.Join(fs.ConfigStringFull(f), fileNameVersion)
 			// Make sure --s3-versions is set in the config of the new remote
 			fs.Debugf(nil, "oldPath = %q", newPath)
 			lastColon := strings.LastIndex(newPath, ":")
@@ -330,7 +330,7 @@ func (f *Fs) InternalTestVersions(t *testing.T) {
 			require.Equal(t, fs.ErrorIsFile, err)
 			require.NotNil(t, fNew)
 			// With the directory the directory above
-			assert.Equal(t, dirName, path.Base(fs.ConfigString(fNew)))
+			assert.Equal(t, dirName, path.Base(fs.ConfigStringFull(fNew)))
 		})
 	})
 
diff --git a/fs/newfs_test.go b/fs/newfs_test.go
index 3f86cd2d5..4d5ef8520 100644
--- a/fs/newfs_test.go
+++ b/fs/newfs_test.go
@@ -32,12 +32,14 @@ func TestNewFs(t *testing.T) {
 	assert.Equal(t, ":mockfs{S_NHG}", f2.Name())
 	assert.Equal(t, "/tmp", f2.Root())
 
-	assert.Equal(t, ":mockfs,potato='true':/tmp", fs.ConfigString(f2))
+	assert.Equal(t, ":mockfs{S_NHG}:/tmp", fs.ConfigString(f2))
+	assert.Equal(t, ":mockfs,potato='true':/tmp", fs.ConfigStringFull(f2))
 
 	f3, err := fs.NewFs(ctx, ":mockfs,potato='true':/tmp")
 	require.NoError(t, err)
 	assert.Equal(t, ":mockfs{S_NHG}", f3.Name())
 	assert.Equal(t, "/tmp", f3.Root())
 
-	assert.Equal(t, ":mockfs,potato='true':/tmp", fs.ConfigString(f3))
+	assert.Equal(t, ":mockfs{S_NHG}:/tmp", fs.ConfigString(f3))
+	assert.Equal(t, ":mockfs,potato='true':/tmp", fs.ConfigStringFull(f3))
 }