mirror of
https://github.com/drakkan/sftpgo.git
synced 2026-03-14 14:25:52 +01:00
config: reset invalid rename mode
Signed-off-by: Nicola Murino <nicola.murino@gmail.com>
This commit is contained in:
parent
e689d52dca
commit
91340bbe2f
2 changed files with 26 additions and 0 deletions
|
|
@ -813,6 +813,12 @@ func resetInvalidConfigs() {
|
|||
logger.WarnToConsole("Non-fatal configuration error: %v", warn)
|
||||
}
|
||||
}
|
||||
if globalConf.Common.RenameMode < 0 || globalConf.Common.RenameMode > 1 {
|
||||
warn := fmt.Sprintf("invalid rename mode %d, reset to 0", globalConf.Common.RenameMode)
|
||||
globalConf.Common.RenameMode = 0
|
||||
logger.Warn(logSender, "", "Non-fatal configuration error: %v", warn)
|
||||
logger.WarnToConsole("Non-fatal configuration error: %v", warn)
|
||||
}
|
||||
}
|
||||
|
||||
func loadBindingsFromEnv() {
|
||||
|
|
|
|||
|
|
@ -243,6 +243,26 @@ func TestInvalidInstallationHint(t *testing.T) {
|
|||
assert.NoError(t, err)
|
||||
}
|
||||
|
||||
func TestInvalidRenameMode(t *testing.T) {
|
||||
reset()
|
||||
|
||||
confName := tempConfigName + ".json"
|
||||
configFilePath := filepath.Join(configDir, confName)
|
||||
commonConfig := config.GetCommonConfig()
|
||||
commonConfig.RenameMode = 10
|
||||
c := make(map[string]any)
|
||||
c["common"] = commonConfig
|
||||
jsonConf, err := json.Marshal(c)
|
||||
assert.NoError(t, err)
|
||||
err = os.WriteFile(configFilePath, jsonConf, os.ModePerm)
|
||||
assert.NoError(t, err)
|
||||
err = config.LoadConfig(configDir, confName)
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, 0, config.GetCommonConfig().RenameMode)
|
||||
err = os.Remove(configFilePath)
|
||||
assert.NoError(t, err)
|
||||
}
|
||||
|
||||
func TestDefenderProviderDriver(t *testing.T) {
|
||||
if config.GetProviderConf().Driver != dataprovider.SQLiteDataProviderName {
|
||||
t.Skip("this test is not supported with the current database provider")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue