allow system log to be cleared

This commit is contained in:
Shaun Walker
2023-02-08 14:45:20 -05:00
parent 2a12744cd5
commit db73052ee5
6 changed files with 67 additions and 24 deletions

View File

@ -84,7 +84,7 @@ namespace Oqtane.Controllers
{
foreach(KeyValuePair<string, object> kvp in settings)
{
_configManager.AddOrUpdateSetting(kvp.Key, kvp.Value, false);
UpdateSetting(kvp.Key, kvp.Value);
}
}
@ -93,7 +93,24 @@ namespace Oqtane.Controllers
[Authorize(Roles = RoleNames.Host)]
public void Put(string key, object value)
{
_configManager.AddOrUpdateSetting(key, value, false);
UpdateSetting(key, value);
}
private void UpdateSetting(string key, object value)
{
switch (key)
{
case "Log":
string path = Path.Combine(_environment.ContentRootPath, "Content", "Log", "error.log");
if (System.IO.File.Exists(path))
{
System.IO.File.Delete(path);
}
break;
default:
_configManager.AddOrUpdateSetting(key, value, false);
break;
}
}
}
}