MCPcopy
hub / github.com/pocketbase/pocketbase / ReloadSettings

Method ReloadSettings

core/settings_query.go:29–50  ·  view source on GitHub ↗

ReloadSettings initializes and reloads the stored application settings. If no settings were stored it will persist the current app ones.

()

Source from the content-addressed store, hash-verified

27//
28// If no settings were stored it will persist the current app ones.
29func (app *BaseApp) ReloadSettings() error {
30 param := &Param{}
31 err := app.ModelQuery(param).Model(paramsKeySettings, param)
32 if err != nil && !errors.Is(err, sql.ErrNoRows) {
33 return err
34 }
35
36 // no settings were previously stored -> save
37 // (ReloadSettings() will be invoked again by a system hook after successful save)
38 if param.Id == "" {
39 // force insert in case the param entry was deleted manually after application start
40 app.Settings().MarkAsNew()
41 return app.Save(app.Settings())
42 }
43
44 event := new(SettingsReloadEvent)
45 event.App = app
46
47 return app.OnSettingsReload().Trigger(event, func(e *SettingsReloadEvent) error {
48 return e.App.Settings().loadParam(e.App, param)
49 })
50}
51
52// loadParam loads the settings from the stored param into the app ones.
53//

Callers 1

BootstrapMethod · 0.95

Calls 10

ModelQueryMethod · 0.95
SettingsMethod · 0.95
SaveMethod · 0.95
OnSettingsReloadMethod · 0.95
ModelMethod · 0.80
IsMethod · 0.80
TriggerMethod · 0.80
loadParamMethod · 0.80
MarkAsNewMethod · 0.65
SettingsMethod · 0.65

Tested by

no test coverage detected