I use Syncthing to distribute data from a central server to remote devices every night. For this I setup a new folder configuration and after the sync is reported to be complete to all devices I remove the folder from the config files.
I now noticed that on each remote device are about 50 syncthing tmp files with the name: .syncthing.fileName.tmp left over. I would like to leave the folder in a clean state.
Is there a cleaner way to remove the folder, which removes tmp files or should I do it by hand?
Temporary files are removed after 24h.
However leftover syncthing.*.tmp files are a sign of incomplete or aborted sync progress, so you should probably investigate that (possible question: are the non-temporary files really equivalent to the source and are the temp files also equivalent or different?).
Do I guess correctly, that they are not removed when the folder is not synced anymore?
I will run a thorough check, but as far as I have seen those are temporary copies of files that were removed on the master (probably during the downloading process)
and therefore should not be there anymore.
They are removed, if they are below an “active” folder root (active as in there is a Syncthing instance running and scanning this dir).
I didn’t check, but that sounds like a probable explanation. I.e. the temp file for the aborted item will stay around, and the subsequent deletion won’t be pulled in, because the item was never successfully pulled (i.e. it doesn’t exist, so pulling a deletion is a noop). And even if the deletion was pulled, I am not sure whether we do also check if there is a temp file and remove that as well (sounds like something we should do).
I have to make an correction on what i said before.
The files exist on both sides and are exactly identical.
I checked all the files if they exist or if they are deleted on both sides and they actually are all existing on both the master as well as the slave.
I thought it might be deletions, because near the end of the sync are almost only deletions.
I now wrote a script to check all files on all devices and I have between 50 and 450 leftover syncthing tmp files after syncing 300 000 files. In all of these cases the file was synced successfully and is identical to the original file.
I guess these are only leftovers which I can just delete with my script.
I am not sure if it is reasonable for you to do a cleanup once the folder is unsynced. I know my case of creating folders every day is not your usual usecase.
I will probably just clean them up with find like you said.
I checked the results again today and this time I found both: Files that were deleted on both sides and files that exist on both sides. This means that the temporary files are just left over from interrupted sync processes.