fix: don't try to import config if it's not present in export file

This commit is contained in:
spiral 2022-05-25 06:32:24 -04:00
parent 3dbfe3c1a5
commit 40955ffc69
No known key found for this signature in database
GPG Key ID: 244A11E4B0BCF40E

View File

@ -30,10 +30,9 @@ public partial class BulkImporter
await _repo.UpdateSystem(_system.Id, patch, _conn); await _repo.UpdateSystem(_system.Id, patch, _conn);
var configPatch = new SystemConfigPatch();
if (importFile.ContainsKey("config")) if (importFile.ContainsKey("config"))
configPatch = SystemConfigPatch.FromJson(importFile.Value<JObject>("config")); {
var configPatch = SystemConfigPatch.FromJson(importFile.Value<JObject>("config"));
if (importFile.ContainsKey("timezone")) if (importFile.ContainsKey("timezone"))
configPatch.UiTz = importFile.Value<string>("timezone"); configPatch.UiTz = importFile.Value<string>("timezone");
@ -43,10 +42,11 @@ public partial class BulkImporter
throw new ImportException($"Field config.{patch.Errors[0].Key} in export file is invalid."); throw new ImportException($"Field config.{patch.Errors[0].Key} in export file is invalid.");
await _repo.UpdateSystemConfig(_system.Id, configPatch, _conn); await _repo.UpdateSystemConfig(_system.Id, configPatch, _conn);
}
var members = importFile.Value<JArray>("members"); var members = importFile.Value<JArray>("members");
var groups = importFile.Value<JArray>("groups");
var switches = importFile.Value<JArray>("switches"); var switches = importFile.Value<JArray>("switches");
var groups = importFile.Value<JArray>("groups");
var newMembers = members.Count(m => var newMembers = members.Count(m =>
{ {