Repository: syncthing/syncthing
File: lib/model/model.go (Go)

Code before:
			}
			return tempIndexFolders, paused, err
		}
		if devErrs, ok := m.folderEncryptionFailures[folder.ID]; ok {
			if len(devErrs) == 1 {
				delete(m.folderEncryptionFailures, folder.ID)
			} else {
				delete(m.folderEncryptionFailures[folder.ID], deviceID)
			}
		}

		// Handle indexes

		if !folder.DisableTempIndexes {
			tempIndexFolders = append(tempIndexFolders, folder.ID)
		}

		indexHandlers.AddIndexInfo(folder.ID, ccDeviceInfos[folder.ID])
	}

	indexHandlers.RemoveAllExcept(seenFolders)
	expiredPendingList := make([]map[string]string, 0, len(expiredPending))
	for folder := range expiredPending {
		if err = m.db.RemovePendingFolderForDevice(folder, deviceID); err != nil {
			msg := "Failed to remove pending folder-device entry"
			l.Warnf("%v (%v, %v): %v", folder, deviceID, msg, err)
			m.evLogger.Log(events.Failure, msg)
			continue
		}
		expiredPendingList = append(expiredPendingList, map[string]string{
			"folderID": folder,
			"deviceID": deviceID.String(),
		})
	}
	if len(updatedPending) > 0 || len(expiredPendingList) > 0 {
		m.evLogger.Log(events.PendingFoldersChanged, map[string]interface{}{
			"added":   updatedPending,
			"removed": expiredPendingList,
		})
	}

	return tempIndexFolders, paused, nil
}

func (m *model) ccCheckEncryption(fcfg config.FolderConfiguration, folderDevice config.FolderDeviceConfiguration, ccDeviceInfos *clusterConfigDeviceInfo, deviceUntrusted bool) error {
	hasTokenRemote := len(ccDeviceInfos.remote.EncryptionPasswordToken) > 0
	hasTokenLocal := len(ccDeviceInfos.local.EncryptionPasswordToken) > 0
	isEncryptedRemote := folderDevice.EncryptionPassword != ""
	isEncryptedLocal := fcfg.Type == config.FolderTypeReceiveEncrypted

	if !isEncryptedRemote && !isEncryptedLocal && deviceUntrusted {

Review comment (suggestion):
```suggestion
			l.Warnf("%v (%v, %v): %v", msg, folder, deviceID, err)
```

Code after:
			}
			return tempIndexFolders, paused, err
		}
		if devErrs, ok := m.folderEncryptionFailures[folder.ID]; ok {
			if len(devErrs) == 1 {
				delete(m.folderEncryptionFailures, folder.ID)
			} else {
				delete(m.folderEncryptionFailures[folder.ID], deviceID)
			}
		}

		// Handle indexes

		if !folder.DisableTempIndexes {
			tempIndexFolders = append(tempIndexFolders, folder.ID)
		}

		indexHandlers.AddIndexInfo(folder.ID, ccDeviceInfos[folder.ID])
	}

	indexHandlers.RemoveAllExcept(seenFolders)
	expiredPendingList := make([]map[string]string, 0, len(expiredPending))
	for folder := range expiredPending {
		if err = m.db.RemovePendingFolderForDevice(folder, deviceID); err != nil {
			msg := "Failed to remove pending folder-device entry"
			l.Warnf("%v (%v, %v): %v", msg, folder, deviceID, err)
			m.evLogger.Log(events.Failure, msg)
			continue
		}
		expiredPendingList = append(expiredPendingList, map[string]string{
			"folderID": folder,
			"deviceID": deviceID.String(),
		})
	}
	if len(updatedPending) > 0 || len(expiredPendingList) > 0 {
		m.evLogger.Log(events.PendingFoldersChanged, map[string]interface{}{
			"added":   updatedPending,
			"removed": expiredPendingList,
		})
	}

	return tempIndexFolders, paused, nil
}

func (m *model) ccCheckEncryption(fcfg config.FolderConfiguration, folderDevice config.FolderDeviceConfiguration, ccDeviceInfos *clusterConfigDeviceInfo, deviceUntrusted bool) error {
	hasTokenRemote := len(ccDeviceInfos.remote.EncryptionPasswordToken) > 0
	hasTokenLocal := len(ccDeviceInfos.local.EncryptionPasswordToken) > 0
	isEncryptedRemote := folderDevice.EncryptionPassword != ""
	isEncryptedLocal := fcfg.Type == config.FolderTypeReceiveEncrypted

	if !isEncryptedRemote && !isEncryptedLocal && deviceUntrusted {