Exemple #1
0
func amendSetting(store *storage.Storage, tx *storage.Tx, name, value string) error {
	if name == "" {
		return fmt.Errorf("setting name must be specified")
	}
	if value == "" {
		return fmt.Errorf("setting '%v' value must be specified", name)
	}

	setting, err := store.Setting(tx, name)
	if err != nil {
		return fmt.Errorf("could not retrieve setting '%v'", err)
	}
	if setting == nil {
		return fmt.Errorf("no such setting '%v'", name)
	}

	if _, err = store.UpdateSetting(tx, name, value); err != nil {
		return fmt.Errorf("could not update setting '%v': %v", name, err)
	}

	return nil
}