Repository: syncthing/syncthing (language: go)

Issue:
Auto-accepted receive-encrypted folders should have more sensible defaults
Right now I have a large folder with many items set up as "Receive Encrypted" and I was having issues where Syncthing was warning me that it was failing to watch for changes as it was hitting the inotifiy limits. With normal folder types I would understand, but watching for changes seems pointless for "Receive Encrypted" folders as there shouldn't be any changes happening on that device.

I think it would be great if "Watch for changes" were automatically disabled on "Receive Encrypted" folders as it would save memory on the device as no local changes should be happening on those folder and if there are they can be caught by periodic scanning.

Also I might be missing something about "Watch for changes" and why it might still be useful for "Receive Encrypted" folders.
Auto-accepted receive-encrypted folders should have more sensible defaults
Right now I have a large folder with many items set up as "Receive Encrypted" and I was having issues where Syncthing was warning me that it was failing to watch for changes as it was hitting the inotifiy limits. With normal folder types I would understand, but watching for changes seems pointless for "Receive Encrypted" folders as there shouldn't be any changes happening on that device.

I think it would be great if "Watch for changes" were automatically disabled on "Receive Encrypted" folders as it would save memory on the device as no local changes should be happening on those folder and if there are they can be caught by periodic scanning.

Also I might be missing something about "Watch for changes" and why it might still be useful for "Receive Encrypted" folders.


Discussion / hints:
"Watch for changes" is already disabled by default when the folder type is set to "Receive Encrypted", so unless you've enabled it manually, it should have stayed like that.

Have you, by any chance, encountered a situation, where it ended up being enabled? If yes, please describe the details.
That doesn't seem to be working properly as I was just able to reproduce it by sharing a new encrypted folder and verified that the folder on the receiving device had "Watch for Changes" checked.
Can you elaborate what you mean by "sharing a new encrypted folder"?

This is what I've just done.

1. On Device 1, add a new folder to Syncthing.
2. Share the folder with Device 2, protecting it with a password.
3. On Device 2, wait for the notification to show up, then click the "Add" button.
4. The folder type is automatically set to Receive Encrypted with the following settings:

    ![image](https://user-images.githubusercontent.com/5626656/164997280-ff8f7b21-b234-45e1-b839-44b089a3ad45.png)

Is this what you're trying to do or, if not, please describe in details all the steps that you're taking. Also, just to make sure, are you running the newest version of Syncthing on both sides? The current release is v1.19.2.
Yup, that's exactly what I've done except I had auto-accept enabled on the receiver. The initiator is v1.19.2, Linux (64-bit Intel/AMD) and the receiver is v1.19.2, Linux (32-bit ARM).

I also just found "Folder Defaults" and saw it was enabled there and just disabled it after my tests. However, I'm not sure if that is enabled by default or it somehow got enabled sometime.
Auto Accept is the culprit here. With it enabled, the folders are created using what is set in Folder Defaults, with no regard for the folder type-specific defaults.

![image](https://user-images.githubusercontent.com/5626656/165046918-52888dcb-6391-4385-93e3-e6eb58514b6d.png)

I'd suggest to change the issue title to something like "Receive Encrypted folders have Watch for Changes enabled and Full Rescan Interval set to 3600 when added using Auto Accept" or similar.

This may tricky to fix though, as Syncthing would have to override the user defaults here. On the other hand, it already does by automatically setting the folder type to Receive Encrypted when auto accepting password-protected folders instead of what's specified in the defaults, so this could probably be treated as an exception. Maybe do this only if the default folder type is not set to Receive Encrypted? If it is though, then just follow what's set in the defaults.

Yeah it seems reasonable to make exceptions for these values when auto-accepting receive encrypted folders since it's already doing it for receive encrypted and those other values are useless for receive encrypted folders.
"Watch for changes" is already disabled by default when the folder type is set to "Receive Encrypted", so unless you've enabled it manually, it should have stayed like that.

Have you, by any chance, encountered a situation, where it ended up being enabled? If yes, please describe the details.
That doesn't seem to be working properly as I was just able to reproduce it by sharing a new encrypted folder and verified that the folder on the receiving device had "Watch for Changes" checked.
Can you elaborate what you mean by "sharing a new encrypted folder"?

This is what I've just done.

1. On Device 1, add a new folder to Syncthing.
2. Share the folder with Device 2, protecting it with a password.
3. On Device 2, wait for the notification to show up, then click the "Add" button.
4. The folder type is automatically set to Receive Encrypted with the following settings:

    ![image](https://user-images.githubusercontent.com/5626656/164997280-ff8f7b21-b234-45e1-b839-44b089a3ad45.png)

Is this what you're trying to do or, if not, please describe in details all the steps that you're taking. Also, just to make sure, are you running the newest version of Syncthing on both sides? The current release is v1.19.2.
Yup, that's exactly what I've done except I had auto-accept enabled on the receiver. The initiator is v1.19.2, Linux (64-bit Intel/AMD) and the receiver is v1.19.2, Linux (32-bit ARM).

I also just found "Folder Defaults" and saw it was enabled there and just disabled it after my tests. However, I'm not sure if that is enabled by default or it somehow got enabled sometime.
Auto Accept is the culprit here. With it enabled, the folders are created using what is set in Folder Defaults, with no regard for the folder type-specific defaults.

![image](https://user-images.githubusercontent.com/5626656/165046918-52888dcb-6391-4385-93e3-e6eb58514b6d.png)

I'd suggest to change the issue title to something like "Receive Encrypted folders have Watch for Changes enabled and Full Rescan Interval set to 3600 when added using Auto Accept" or similar.

This may tricky to fix though, as Syncthing would have to override the user defaults here. On the other hand, it already does by automatically setting the folder type to Receive Encrypted when auto accepting password-protected folders instead of what's specified in the defaults, so this could probably be treated as an exception. Maybe do this only if the default folder type is not set to Receive Encrypted? If it is though, then just follow what's set in the defaults.

Yeah it seems reasonable to make exceptions for these values when auto-accepting receive encrypted folders since it's already doing it for receive encrypted and those other values are useless for receive encrypted folders.

Fix patch:
diff --git a/lib/model/model.go b/lib/model/model.go
index 042a69d3dcf..d64d012699d 100644
--- a/lib/model/model.go
+++ b/lib/model/model.go
@@ -1675,6 +1675,11 @@ func (m *model) handleAutoAccepts(deviceID protocol.DeviceID, folder protocol.Fo
 
 			if len(ccDeviceInfos.remote.EncryptionPasswordToken) > 0 || len(ccDeviceInfos.local.EncryptionPasswordToken) > 0 {
 				fcfg.Type = config.FolderTypeReceiveEncrypted
+				// Override the user-configured defaults, as normally done by the GUI
+				fcfg.FSWatcherEnabled = false
+				fcfg.RescanIntervalS = 3600 * 24
+				fcfg.Versioning.Reset()
+				// Other necessary settings are ensured by FolderConfiguration itself
 			} else {
 				ignores := m.cfg.DefaultIgnores()
 				if err := m.setIgnores(fcfg, ignores.Lines); err != nil {


Test patch: