The other way is just to rename them and then chill out. Seriously. Just wait.
If you start looking at what’s going on you’ll get in a panic and mess it up by trying to ‘fix’ it.
If you rename and walk away, Syncthing will take care of it. It just takes time while it crunches the numbers. You just need to make sure that nobody’s using the remote end while this happens.
This is real issue though, e.g. if you only have 100GB of mobile data left and you’ve renamed a 300GB folder, which now has to transfer all its contents again, or if you’re using a very slow connection, where transferring 300GB can take days . In other words, it’s understandable that many people would like Syncthing to handle these kind of renames better.
How did you confirm that the 3 sets of files were actually re-uploaded?
I’ve renamed individual files many times with Syncthing exchanging a minimal amount of data…
As a test, I renamed a 544MB file. With Syncthing’s default 10-second countdown timer, it took 11 seconds for the sync to finish.
Transferring 544MB in 1 second requires 4.5Gbps, but I’ve got a 1 GbE network switch and bandwidth throttling on each server capped at 200 Mbps, so only Syncthing detecting and acting on the rename makes it possible.
I saw it displayed on the Syncthing website, that it is uploading and have the “Stats” utility that showed the actual upload rate - and no, nothing else was uploading!
The files each are around 2GB, so 3 pairs of files is exactly 12 GB, what was shown on the Syncthing website!
And when Synching was finished, Stats also showed that nothing get’s uploaded anymore.
With the download / upload rate counter reset to zero for easier reference, renaming a 544MB file required 264KB of data from a send-only device to a receive-only device:
Upload rate peaked at 4.64 Kbps (with the sync finishing in just 1 second I didn’t have enough time to grab a screenshot).
Since normally two things cannot be true at the same time, either my servers are capable of quantum teleportation (I wish ), or there’s something unusual about yours.
Maybe I missed it, but I didn’t see a more detailed description about your setup in terms of OSes, filesystems, etc.
And to explain why this is needed, in that case we talk about movies and shows for a Jellyfin server and I have bad naming of episodes - their sequence is wrong and needs to be fixed, most of the time by exchanging the names of two files … or circle rename several of them.
Yes, pretty much the same effect as renaming a folder. The pair of files are processed by Syncthing within the same batch.
Remember, for efficiency reasons there’s a default 10-second countdown timer that delays processing.
I also have the same naming issues with my video and music collection.
Given the following conditions:
You’ve confirmed that renaming files one by one works as expected.
If you’re not renaming files in bulk using a script or other tool, you’re unlikely to be able to name swap a pair of files in a couple of seconds or less.
You mentioned that your send-only server isn’t set to do automated rescans.
Change the fsWatcherDelayS from the default 10 seconds to 0 – since you don’t usually use it, you won’t need to revert it back to the default.
Then, whenever you want to name swap, temporarily enable file watching (“Watch for Changes”) which fsWatcherDelayS is dependent on.
With fsWatcherDelayS set to 0, Syncthing will act immediately on a rename, scanning and pushing the rename across the wire. Take a breath, then continue with the rest of the steps – i.e. rename A → C, breath, rename B → A, breath, rename C → B.
The idea is to allow each stage of the “circle rename” to complete in its own Syncthing batch process.
These kinds of workarounds are a pain.
It really would be great if for specific folders we could specify that all scanning should complete before sending any changes and hashes for changed files could all be matched with existing files after the updates are sent and files or directories are moved or renamed before any transfers begin.
This could be an option disabled by default and on existing directories but could be changed if this special behavior is useful for a specific folder where large files or directories are regularly renamed.
As it is now, things can get ugly if large files or directories are renamed with many many GBs being retransmitted and many many GB of files being moved to stversions unexpectedly instead of just being renamed.
This is very much a special case, and indeed not supported. For clarity, this is how Syncthing’s rename detection works:
When a new file is scanned, it’s hash is determined.
When it is going to be inserted into the database, we ask for other files in the folder that have the exact same hash
For any matches, we check if they still exist on disk.
If they do not, we insert the delete as a paired entry to the new file.
On the receiving side, we look for add+delete pairs and convert to rename.
This won’t work if you switch the names of two files between each other. I expect that’s a rather unusual operation, and one that can’t even be represented on the destination as an ordered set of renames from source to destination.
It should work fine for 1 file or 1000 files though, including renaming a folder with a lot of files in it, so if it doesn’t that’s something for someone to troubleshoot.
I just found a solution for the problem (which is an incredible common problem between all people I personally know that use Syncthing - they all sync their media libraries, and here you have that problem!)
The WORKAROUND is as follow:
mkdir TMP
mv A TMP/B
mv B TMP/A
resync
mv TMP/* .
resync
Works, as far as I tested - also more many files and folders that need to be renamed.
I am currently scripting this, as I will need it hundreds of times, now and in the future.