mirror of
https://github.com/Radarr/Radarr.git
synced 2026-04-23 22:25:14 -04:00
Fixed: Saving settings changes
This commit is contained in:
@@ -8,7 +8,7 @@ namespace NzbDrone.Core.Configuration
|
||||
public interface IConfigRepository : IBasicRepository<Config>
|
||||
{
|
||||
Config Get(string key);
|
||||
|
||||
Config Upsert(string key, string value);
|
||||
}
|
||||
|
||||
public class ConfigRepository : BasicRepository<Config>, IConfigRepository
|
||||
@@ -23,5 +23,19 @@ namespace NzbDrone.Core.Configuration
|
||||
{
|
||||
return Query.Where(c => c.Key == key).SingleOrDefault();
|
||||
}
|
||||
|
||||
public Config Upsert(string key, string value)
|
||||
{
|
||||
var dbValue = Get(key);
|
||||
|
||||
if (dbValue == null)
|
||||
{
|
||||
return Insert(new Config {Key = key, Value = value});
|
||||
}
|
||||
|
||||
dbValue.Value = value;
|
||||
|
||||
return Update(dbValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -376,7 +376,7 @@ namespace NzbDrone.Core.Configuration
|
||||
key = key.ToLowerInvariant();
|
||||
|
||||
_logger.Trace("Writing Setting to database. Key:'{0}' Value:'{1}'", key, value);
|
||||
_repository.Upsert(new Config {Key = key, Value = value});
|
||||
_repository.Upsert(key, value);
|
||||
|
||||
ClearCache();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user