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

Code before:
	if !reflect.DeepEqual(from.Options.RequiresRestartOnly(), to.Options.RequiresRestartOnly()) {
		l.Debugln(m, "requires restart, options differ")
		return false
	}

	return true
}

func (m *model) cleanPending(existingDevices map[protocol.DeviceID]config.DeviceConfiguration, existingFolders map[string]config.FolderConfiguration, ignoredDevices deviceIDSet, removedFolders map[string]struct{}) {
	var removedPendingFolders []map[string]string
	pendingFolders, err := m.db.PendingFolders()
	if err != nil {
		msg := "Could not iterate through pending folder entries for cleanup"
		l.Warnf("%v: %v", msg, err)
		m.evLogger.Log(events.Failure, msg)
		// Continue with pending devices below, loop is skipped.
	}
	for folderID, pf := range pendingFolders {
		if _, ok := removedFolders[folderID]; ok {
			// Forget pending folder device associations for recently removed
			// folders as well, assuming the folder is no longer of interest
			// at all (but might become pending again).
			l.Debugf("Discarding pending removed folder %v from all devices", folderID)
			if err := m.db.RemovePendingFolder(folderID); err != nil {
				msg := "Failed to remove pending folder entry"
				l.Warnf("%v (%v): %v", folderID, msg, err)
				m.evLogger.Log(events.Failure, msg)
			} else {
				removedPendingFolders = append(removedPendingFolders, map[string]string{
					"folderID": folderID,
				})
			}
			continue
		}
		for deviceID := range pf.OfferedBy {
			if dev, ok := existingDevices[deviceID]; !ok {
				l.Debugf("Discarding pending folder %v from unknown device %v", folderID, deviceID)
				goto removeFolderForDevice
			} else if dev.IgnoredFolder(folderID) {
				l.Debugf("Discarding now ignored pending folder %v for device %v", folderID, deviceID)
				goto removeFolderForDevice
			}
			if folderCfg, ok := existingFolders[folderID]; ok {
				if folderCfg.SharedWith(deviceID) {
					l.Debugf("Discarding now shared pending folder %v for device %v", folderID, deviceID)
					goto removeFolderForDevice
				}
			}
			continue
		removeFolderForDevice:
			if err := m.db.RemovePendingFolderForDevice(folderID, deviceID); err != nil {

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

Code after:
	if !reflect.DeepEqual(from.Options.RequiresRestartOnly(), to.Options.RequiresRestartOnly()) {
		l.Debugln(m, "requires restart, options differ")
		return false
	}

	return true
}

func (m *model) cleanPending(existingDevices map[protocol.DeviceID]config.DeviceConfiguration, existingFolders map[string]config.FolderConfiguration, ignoredDevices deviceIDSet, removedFolders map[string]struct{}) {
	var removedPendingFolders []map[string]string
	pendingFolders, err := m.db.PendingFolders()
	if err != nil {
		msg := "Could not iterate through pending folder entries for cleanup"
		l.Warnf("%v: %v", msg, err)
		m.evLogger.Log(events.Failure, msg)
		// Continue with pending devices below, loop is skipped.
	}
	for folderID, pf := range pendingFolders {
		if _, ok := removedFolders[folderID]; ok {
			// Forget pending folder device associations for recently removed
			// folders as well, assuming the folder is no longer of interest
			// at all (but might become pending again).
			l.Debugf("Discarding pending removed folder %v from all devices", folderID)
			if err := m.db.RemovePendingFolder(folderID); err != nil {
				msg := "Failed to remove pending folder entry"
				l.Warnf("%v (%v): %v", msg, folderID, err)
				m.evLogger.Log(events.Failure, msg)
			} else {
				removedPendingFolders = append(removedPendingFolders, map[string]string{
					"folderID": folderID,
				})
			}
			continue
		}
		for deviceID := range pf.OfferedBy {
			if dev, ok := existingDevices[deviceID]; !ok {
				l.Debugf("Discarding pending folder %v from unknown device %v", folderID, deviceID)
				goto removeFolderForDevice
			} else if dev.IgnoredFolder(folderID) {
				l.Debugf("Discarding now ignored pending folder %v for device %v", folderID, deviceID)
				goto removeFolderForDevice
			}
			if folderCfg, ok := existingFolders[folderID]; ok {
				if folderCfg.SharedWith(deviceID) {
					l.Debugf("Discarding now shared pending folder %v for device %v", folderID, deviceID)
					goto removeFolderForDevice
				}
			}
			continue
		removeFolderForDevice:
			if err := m.db.RemovePendingFolderForDevice(folderID, deviceID); err != nil {