Repository: rclone/rclone (language: go)

Issue:
Bisync should be considered experimental
#### The associated forum post URL from `https://forum.rclone.org`
https://forum.rclone.org/t/bisync-should-be-considered-experimental/29879

#### What is your current rclone version (output from `rclone version`)?
not required

#### What problem are you are trying to solve?
Bisync should be considered experimental and the documentation to reflect that.

#### How do you think rclone should be changed to solve that?
1. https://rclone.org/commands/rclone_bisync/
--- should be labeled `experimental`
--- should have a scary warning, some suggestions are
"Warning, `rclone bisync is advanced command, that is considered experimental. Use at your own risk.
"Can delete files on BOTH the source and dest"
"Can result in the permanent loss of files on the source and dest"
"Important: Since this can cause data loss, test first with the --dry-run or the --interactive/-i flag."

<!--- Please keep the note below for others who read your feature request. -->

#### How to use GitHub

* Please use the 👍 [reaction](https://blog.github.com/2016-03-10-add-reactions-to-pull-requests-issues-and-comments/) to show that you are affected by the same issue.
* Please don't comment if you have no relevant information to add. It's just extra noise for everyone subscribed to this issue.
* Subscribe to receive notifications on status change and new comments.



Discussion / hints:
Feel free to submit a PR as that gets reviewed and you can make updates as agreed upon.
I am aware that it's an experimental, so what's the state of `rclone bisync`?  is it in alpha or beta? 
> I am aware that it's an experimental, so what's the state of `rclone bisync`? is it in alpha or beta?

the state is `unmaintained ` as per
https://forum.rclone.org/t/bisync-bugs-and-feature-requests/37636/3


Fix patch:
diff --git a/cmd/bisync/bilib/canonical.go b/cmd/bisync/bilib/canonical.go
index be99d7f2d8376..dac147670287c 100644
--- a/cmd/bisync/bilib/canonical.go
+++ b/cmd/bisync/bilib/canonical.go
@@ -2,12 +2,15 @@
 package bilib
 
 import (
+	"context"
 	"os"
+	"path/filepath"
 	"regexp"
 	"runtime"
 	"strings"
 
 	"github.com/rclone/rclone/fs"
+	"github.com/rclone/rclone/fs/operations"
 )
 
 // FsPath converts Fs to a suitable rclone argument
@@ -38,5 +41,57 @@ var nonCanonicalChars = regexp.MustCompile(`[\s\\/:?*]`)
 
 // SessionName makes a unique base name for the sync operation
 func SessionName(fs1, fs2 fs.Fs) string {
-	return CanonicalPath(FsPath(fs1)) + ".." + CanonicalPath(FsPath(fs2))
+	return StripHexString(CanonicalPath(FsPath(fs1))) + ".." + StripHexString(CanonicalPath(FsPath(fs2)))
+}
+
+// StripHexString strips the (first) canonical {hexstring} suffix
+func StripHexString(path string) string {
+	open := strings.IndexRune(path, '{')
+	close := strings.IndexRune(path, '}')
+	if open >= 0 && close > open {
+		return path[:open] + path[close+1:] // (trailing underscore)
+	}
+	return path
+}
+
+// HasHexString returns true if path contains at least one canonical {hexstring} suffix
+func HasHexString(path string) bool {
+	open := strings.IndexRune(path, '{')
+	if open >= 0 && strings.IndexRune(path, '}') > open {
+		return true
+	}
+	return false
+}
+
+// BasePath joins the workDir with the SessionName, stripping {hexstring} suffix if necessary
+func BasePath(ctx context.Context, workDir string, fs1, fs2 fs.Fs) string {
+	suffixedSession := CanonicalPath(FsPath(fs1)) + ".." + CanonicalPath(FsPath(fs2))
+	suffixedBasePath := filepath.Join(workDir, suffixedSession)
+	listing1 := suffixedBasePath + ".path1.lst"
+	listing2 := suffixedBasePath + ".path2.lst"
+
+	sessionName := SessionName(fs1, fs2)
+	basePath := filepath.Join(workDir, sessionName)
+
+	// Normalize to non-canonical version for overridden configs
+	// to ensure that backend-specific flags don't change the listing filename.
+	// For backward-compatibility, we first check if we found a listing file with the suffixed version.
+	// If so, we rename it (and overwrite non-suffixed version, if any.)
+	// If not, we carry on with the non-suffixed version.
+	// We should only find a suffixed version if bisync v1.66 or older created it.
+	if HasHexString(suffixedSession) && FileExists(listing1) {
+		fs.Infof(listing1, "renaming to: %s", basePath+".path1.lst")
+		if !operations.SkipDestructive(ctx, listing1, "rename to "+basePath+".path1.lst") {
+			_ = os.Rename(listing1, basePath+".path1.lst")
+		}
+	}
+	if HasHexString(suffixedSession) && FileExists(listing2) {
+		fs.Infof(listing2, "renaming to: %s", basePath+".path2.lst")
+		if !operations.SkipDestructive(ctx, listing1, "rename to "+basePath+".path2.lst") {
+			_ = os.Rename(listing2, basePath+".path2.lst")
+		} else {
+			return suffixedBasePath
+		}
+	}
+	return basePath
 }
diff --git a/cmd/bisync/cmd.go b/cmd/bisync/cmd.go
index fafbfaff5506f..76768248e977c 100644
--- a/cmd/bisync/cmd.go
+++ b/cmd/bisync/cmd.go
@@ -138,6 +138,7 @@ var commandDefinition = &cobra.Command{
 	Annotations: map[string]string{
 		"versionIntroduced": "v1.58",
 		"groups":            "Filter,Copy,Important",
+		"status":            "Beta",
 	},
 	RunE: func(command *cobra.Command, args []string) error {
 		cmd.CheckArgs(2, 2, command, args)
@@ -163,7 +164,7 @@ var commandDefinition = &cobra.Command{
 			}
 		}
 
-		fs.Logf(nil, "bisync is EXPERIMENTAL. Don't use in production!")
+		fs.Logf(nil, "bisync is IN BETA. Don't use in production!")
 		cmd.Run(false, true, command, func() error {
 			err := Bisync(ctx, fs1, fs2, &opt)
 			if err == ErrBisyncAborted {
diff --git a/cmd/bisync/help.go b/cmd/bisync/help.go
index 61c944a5928ca..68ad27570320d 100644
--- a/cmd/bisync/help.go
+++ b/cmd/bisync/help.go
@@ -56,5 +56,10 @@ On each successive run it will:
   Changes include |New|, |Newer|, |Older|, and |Deleted| files.
 - Propagate changes on Path1 to Path2, and vice-versa.
 
+Bisync is **in beta** and is considered an **advanced command**, so use with care.
+Make sure you have read and understood the entire [manual](https://rclone.org/bisync)
+(especially the [Limitations](https://rclone.org/bisync/#limitations) section) before using,
+or data loss can result. Questions can be asked in the [Rclone Forum](https://forum.rclone.org/).
+
 See [full bisync description](https://rclone.org/bisync/) for details.
 `)
diff --git a/cmd/bisync/operations.go b/cmd/bisync/operations.go
index d845b4826aec8..e7c56c2f3f261 100644
--- a/cmd/bisync/operations.go
+++ b/cmd/bisync/operations.go
@@ -88,7 +88,7 @@ func Bisync(ctx context.Context, fs1, fs2 fs.Fs, optArg *Options) (err error) {
 	}
 
 	// Produce a unique name for the sync operation
-	b.basePath = filepath.Join(b.workDir, bilib.SessionName(b.fs1, b.fs2))
+	b.basePath = bilib.BasePath(ctx, b.workDir, b.fs1, b.fs2)
 	b.listing1 = b.basePath + ".path1.lst"
 	b.listing2 = b.basePath + ".path2.lst"
 	b.newListing1 = b.listing1 + "-new"
diff --git a/docs/content/bisync.md b/docs/content/bisync.md
index 947128feed143..6d8e5cd1ba8e3 100644
--- a/docs/content/bisync.md
+++ b/docs/content/bisync.md
@@ -2,8 +2,13 @@
 title: "Bisync"
 description: "Bidirectional cloud sync solution in rclone"
 versionIntroduced: "v1.58"
+status: Beta
 ---
 
+## Bisync
+`bisync` is **in beta** and is considered an **advanced command**, so use with care.
+Make sure you have read and understood the entire [manual](https://rclone.org/bisync) (especially the [Limitations](#limitations) section) before using, or data loss can result. Questions can be asked in the [Rclone Forum](https://forum.rclone.org/).
+
 ## Getting started {#getting-started}
 
 - [Install rclone](/install/) and setup your remotes.
@@ -361,7 +366,7 @@ Behavior of `--resilient` may change in a future version.
 
 #### --backup-dir1 and --backup-dir2
 
-As of `v1.65`, [`--backup-dir`](/docs/#backup-dir-dir) is supported in bisync.
+As of `v1.66`, [`--backup-dir`](/docs/#backup-dir-dir) is supported in bisync.
 Because `--backup-dir` must be a non-overlapping path on the same remote,
 Bisync has introduced new `--backup-dir1` and `--backup-dir2` flags to support
 separate backup-dirs for `Path1` and `Path2` (bisyncing between different
@@ -559,9 +564,9 @@ original path on the next sync, resulting in data loss.
 It is therefore recommended to _omit_ `--inplace`.
 
 Files that **change during** a bisync run may result in data loss.
-Prior to `rclone v1.65`, this was commonly seen in highly dynamic environments, where the filesystem
+Prior to `rclone v1.66`, this was commonly seen in highly dynamic environments, where the filesystem
 was getting hammered by running processes during the sync.
-As of `rclone v1.65`, bisync was redesigned to use a "snapshot" model,
+As of `rclone v1.66`, bisync was redesigned to use a "snapshot" model,
 greatly reducing the risks from changes during a sync.
 Changes that are not detected during the current sync will now be detected during the following sync,
 and will no longer cause the entire run to throw a critical error.
@@ -596,7 +601,7 @@ Bisync sees this as all files in the old directory name as deleted and all
 files in the new directory name as new. 
 
 A recommended solution is to use [`--track-renames`](/docs/#track-renames),
-which is now supported in bisync as of `rclone v1.65`.
+which is now supported in bisync as of `rclone v1.66`.
 Note that `--track-renames` is not available during `--resync`,
 as `--resync` does not delete anything (`--track-renames` only supports `sync`, not `copy`.)
 
@@ -614,22 +619,9 @@ and there is also a [known issue concerning Google Drive users with many empty d
 For now, the recommended way to avoid using `--fast-list` is to add `--disable ListR` 
 to all bisync commands. The default behavior may change in a future version.
 
-### Overridden Configs
-
-When rclone detects an overridden config, it adds a suffix like `{ABCDE}` on the fly 
-to the internal name of the remote. Bisync follows suit by including this suffix in its listing filenames. 
-However, this suffix does not necessarily persist from run to run, especially if different flags are provided. 
-So if next time the suffix assigned is `{FGHIJ}`, bisync will get confused, 
-because it's looking for a listing file with `{FGHIJ}`, when the file it wants has `{ABCDE}`. 
-As a result, it throws 
-`Bisync critical error: cannot find prior Path1 or Path2 listings, likely due to critical error on prior run` 
-and refuses to run again until the user runs a `--resync` (unless using `--resilient`). 
-The best workaround at the moment is to set any backend-specific flags in the [config file](/commands/rclone_config/) 
-instead of specifying them with command flags. (You can still override them as needed for other rclone commands.)
-
 ### Case (and unicode) sensitivity {#case-sensitivity}
 
-As of `v1.65`, case and unicode form differences no longer cause critical errors,
+As of `v1.66`, case and unicode form differences no longer cause critical errors,
 and normalization (when comparing between filesystems) is handled according to the same flags and defaults as `rclone sync`.
 See the following options (all of which are supported by bisync) to control this behavior more granularly:
 - [`--fix-case`](/docs/#fix-case)
@@ -923,7 +915,7 @@ consider using the flag
 
 ### Google Docs (and other files of unknown size) {#gdocs}
 
-As of `v1.65`, [Google Docs](/drive/#import-export-of-google-documents)
+As of `v1.66`, [Google Docs](/drive/#import-export-of-google-documents)
 (including Google Sheets, Slides, etc.) are now supported in bisync, subject to
 the same options, defaults, and limitations as in `rclone sync`. When bisyncing
 drive with non-drive backends, the drive -> non-drive direction is controlled
@@ -974,10 +966,6 @@ skip them.) To work around this, use the default (modtime and size) instead of
 To ignore Google Docs entirely, use
 [`--drive-skip-gdocs`](/drive/#drive-skip-gdocs).
 
-(Note that all flags starting with `--drive` are backend-specific, and
-therefore will cause the behavior explained in [Overridden
-Configs](/#overridden-configs).)
-
 ## Usage examples
 
 ### Cron {#cron}
@@ -1354,7 +1342,7 @@ about _Unison_ and synchronization in general.
 
 ## Changelog
 
-### `v1.65`
+### `v1.66`
 * Copies and deletes are now handled in one operation instead of two
 * `--track-renames` and `--backup-dir` are now supported
 * Partial uploads known issue on `local`/`ftp`/`sftp` has been resolved (unless using `--inplace`)
@@ -1369,6 +1357,7 @@ for performance improvements and less [risk of error](https://forum.rclone.org/t
 * Google Docs (and other files of unknown size) are now supported (with the same options as in `sync`)
 * Equality checks before a sync conflict rename now fall back to `cryptcheck` (when possible) or `--download`,
 instead of of `--size-only`, when `check` is not available.
+* Bisync no longer fails to find the correct listing file when configs are overridden with backend-specific flags.
 
 ### `v1.64`
 * Fixed an [issue](https://forum.rclone.org/t/bisync-bugs-and-feature-requests/37636#:~:text=1.%20Dry%20runs%20are%20not%20completely%20dry) 


Test patch: