Fix NPEs in migration scripts

This commit is contained in:
0xb00bface 2023-04-09 18:08:25 +02:00
parent 36fa8cd6b7
commit b2e8be5a59
1 changed files with 9 additions and 3 deletions

View File

@ -190,7 +190,7 @@ public class Config {
private void convertChaturbateModelNamesToLowerCase() {
final String CTB = "chaturbate.com";
// convert mode notes
// convert model notes
Map<String, String> convertedModelNotes = new HashMap<>();
getSettings().modelNotes.forEach((key, value) -> {
if (key.contains(CTB)) {
@ -211,16 +211,21 @@ public class Config {
getSettings().modelPortraits.putAll(convertedModelPortraits);
// convert model groups
getSettings().modelGroups.forEach(mg -> mg.setModelUrls(mg.getModelUrls().stream().map(url -> url.contains(CTB) ? url.toLowerCase() : url)
getSettings().modelGroups.forEach(mg -> mg.setModelUrls(mg.getModelUrls().stream()
.filter(Objects::nonNull)
.map(url -> url.contains(CTB) ? url.toLowerCase() : url)
.collect(Collectors.toList()))); // NOSONAR - has to be mutable
// convert ignored models
getSettings().ignoredModels = getSettings().ignoredModels.stream().map(url -> url.contains(CTB) ? url.toLowerCase() : url)
getSettings().ignoredModels = getSettings().ignoredModels.stream()
.filter(Objects::nonNull)
.map(url -> url.contains(CTB) ? url.toLowerCase() : url)
.collect(Collectors.toList()); // NOSONAR - has to be mutable
// change the model objects
getSettings().models.stream()
.filter(ChaturbateModel.class::isInstance)
.filter(m -> m.getUrl() != null)
.forEach(m -> {
m.setDisplayName(m.getName());
m.setName(m.getName().toLowerCase());
@ -228,6 +233,7 @@ public class Config {
});
getSettings().recordLater.stream()
.filter(ChaturbateModel.class::isInstance)
.filter(m -> m.getUrl() != null)
.forEach(m -> {
m.setDisplayName(m.getName());
m.setName(m.getName().toLowerCase());