mirror of https://github.com/halo-dev/halo
fix: newly added setting item are not taking effect (#4486)
#### What type of PR is this? /kind improvement /area core /milestone 2.9.x #### What this PR does / why we need it: 修复新增加的配置项默认值没有填充的问题 how to test it? 测试插件和主题新增加的配置项(带默认值)在升级后是否具有默认值 #### Which issue(s) this PR fixes: Fixes #4377 #### Does this PR introduce a user-facing change? ```release-note 修复新增加的配置项默认值没有填充的问题 ```pull/4482/head^2
parent
03bf2aea7c
commit
401c3c79ce
|
@ -184,13 +184,6 @@ public class PluginReconciler implements Reconciler<Request> {
|
||||||
Assert.notNull(name, "Plugin name must not be null");
|
Assert.notNull(name, "Plugin name must not be null");
|
||||||
Assert.notNull(settingName, "Setting name must not be null");
|
Assert.notNull(settingName, "Setting name must not be null");
|
||||||
PluginWrapper pluginWrapper = getPluginWrapper(name);
|
PluginWrapper pluginWrapper = getPluginWrapper(name);
|
||||||
// If it already exists, do not look for setting
|
|
||||||
if (RuntimeMode.DEPLOYMENT.equals(pluginWrapper.getRuntimeMode())) {
|
|
||||||
Optional<Setting> existing = client.fetch(Setting.class, settingName);
|
|
||||||
if (existing.isPresent()) {
|
|
||||||
return existing;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var resourceLoader =
|
var resourceLoader =
|
||||||
new DefaultResourceLoader(pluginWrapper.getPluginClassLoader());
|
new DefaultResourceLoader(pluginWrapper.getPluginClassLoader());
|
||||||
|
|
|
@ -166,14 +166,25 @@ public class ThemeServiceImpl implements ThemeService {
|
||||||
})
|
})
|
||||||
.doOnNext(unstructured ->
|
.doOnNext(unstructured ->
|
||||||
populateThemeNameLabel(unstructured, theme.getMetadata().getName()))
|
populateThemeNameLabel(unstructured, theme.getMetadata().getName()))
|
||||||
.flatMap(unstructured -> client.create(unstructured)
|
.flatMap(this::createOrUpdate)
|
||||||
.retryWhen(Retry.backoff(5, Duration.ofMillis(100))
|
|
||||||
.filter(OptimisticLockingFailureException.class::isInstance))
|
|
||||||
)
|
|
||||||
.then(Mono.just(theme));
|
.then(Mono.just(theme));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Mono<Unstructured> createOrUpdate(Unstructured unstructured) {
|
||||||
|
return Mono.defer(() -> client.fetch(unstructured.groupVersionKind(),
|
||||||
|
unstructured.getMetadata().getName())
|
||||||
|
.flatMap(existUnstructured -> {
|
||||||
|
existUnstructured.getMetadata()
|
||||||
|
.setVersion(unstructured.getMetadata().getVersion());
|
||||||
|
return client.update(existUnstructured);
|
||||||
|
})
|
||||||
|
.switchIfEmpty(Mono.defer(() -> client.create(unstructured)))
|
||||||
|
)
|
||||||
|
.retryWhen(Retry.backoff(5, Duration.ofMillis(100))
|
||||||
|
.filter(OptimisticLockingFailureException.class::isInstance));
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Mono<Theme> reloadTheme(String name) {
|
public Mono<Theme> reloadTheme(String name) {
|
||||||
return client.fetch(Theme.class, name)
|
return client.fetch(Theme.class, name)
|
||||||
|
|
Loading…
Reference in New Issue