Skip to content

Commit

Permalink
Suppress rewrite config in db without changes
Browse files Browse the repository at this point in the history
Now Strapi rewrite all 'plugin_content_manager_configuration_content_types' keys in "core_store" database table on each restart.
I add comparison of stored config with generated, and skip unnecessary write config to database, when there are no changes.
  • Loading branch information
MurzNN committed Feb 29, 2020
1 parent 7e7689c commit b8dbf6a
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions packages/strapi-plugin-content-manager/services/utils/store.js
Expand Up @@ -29,18 +29,21 @@ const getModelConfiguration = async key => {
};

const setModelConfiguration = async (key, value) => {
const config = (await getStore().get({ key: configurationKey(key) })) || {};

const storedConfig = (await getStore().get({ key: configurationKey(key) })) || {};
const currentConfig = { ...storedConfig };
Object.keys(value).forEach(key => {
if (value[key] !== null && value[key] !== undefined) {
_.set(config, key, value[key]);
_.set(currentConfig, key, value[key]);
}
});

return getStore().set({
key: configurationKey(key),
value: config,
});
if(JSON.stringify(currentConfig) != JSON.stringify(storedConfig)) {
return getStore().set({
key: configurationKey(key),
value: currentConfig,
});
}

};

const deleteKey = key => {
Expand Down

0 comments on commit b8dbf6a

Please sign in to comment.