This fixes various test issues with Go 1.20. - Most tests rewritten to use fakefs where possible - Some tests that were already skipped, or dubious (invasive, unmaintainable, unclear what they even tested) have been removed - Some actual code rewritten to better support testing in fakefs Co-authored-by: Eric P <eric@kastelo.net>
This commit is contained in:
+5
-5
@@ -1220,7 +1220,7 @@ func (m *model) ClusterConfig(deviceID protocol.DeviceID, cm protocol.ClusterCon
|
||||
haveFcfg := cfg.FolderMap()
|
||||
for _, folder := range cm.Folders {
|
||||
from, ok := haveFcfg[folder.ID]
|
||||
if to, changed := m.handleAutoAccepts(deviceID, folder, ccDeviceInfos[folder.ID], from, ok, cfg.Defaults.Folder.Path); changed {
|
||||
if to, changed := m.handleAutoAccepts(deviceID, folder, ccDeviceInfos[folder.ID], from, ok, cfg.Defaults.Folder); changed {
|
||||
changedFcfg[folder.ID] = to
|
||||
}
|
||||
}
|
||||
@@ -1664,9 +1664,9 @@ func (*model) handleDeintroductions(introducerCfg config.DeviceConfiguration, fo
|
||||
|
||||
// handleAutoAccepts handles adding and sharing folders for devices that have
|
||||
// AutoAcceptFolders set to true.
|
||||
func (m *model) handleAutoAccepts(deviceID protocol.DeviceID, folder protocol.Folder, ccDeviceInfos *clusterConfigDeviceInfo, cfg config.FolderConfiguration, haveCfg bool, defaultPath string) (config.FolderConfiguration, bool) {
|
||||
func (m *model) handleAutoAccepts(deviceID protocol.DeviceID, folder protocol.Folder, ccDeviceInfos *clusterConfigDeviceInfo, cfg config.FolderConfiguration, haveCfg bool, defaultFolderCfg config.FolderConfiguration) (config.FolderConfiguration, bool) {
|
||||
if !haveCfg {
|
||||
defaultPathFs := fs.NewFilesystem(fs.FilesystemTypeBasic, defaultPath)
|
||||
defaultPathFs := fs.NewFilesystem(defaultFolderCfg.FilesystemType, defaultFolderCfg.Path)
|
||||
var pathAlternatives []string
|
||||
if alt := fs.SanitizePath(folder.Label); alt != "" {
|
||||
pathAlternatives = append(pathAlternatives, alt)
|
||||
@@ -1685,13 +1685,13 @@ func (m *model) handleAutoAccepts(deviceID protocol.DeviceID, folder protocol.Fo
|
||||
}
|
||||
|
||||
// Attempt to create it to make sure it does, now.
|
||||
fullPath := filepath.Join(defaultPath, path)
|
||||
fullPath := filepath.Join(defaultFolderCfg.Path, path)
|
||||
if err := defaultPathFs.MkdirAll(path, 0o700); err != nil {
|
||||
l.Warnf("Failed to create path for auto-accepted folder %s at path %s: %v", folder.Description(), fullPath, err)
|
||||
continue
|
||||
}
|
||||
|
||||
fcfg := newFolderConfiguration(m.cfg, folder.ID, folder.Label, fs.FilesystemTypeBasic, fullPath)
|
||||
fcfg := newFolderConfiguration(m.cfg, folder.ID, folder.Label, defaultFolderCfg.FilesystemType, fullPath)
|
||||
fcfg.Devices = append(fcfg.Devices, config.FolderDeviceConfiguration{
|
||||
DeviceID: deviceID,
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user