From 9bdcb088ebddb422cd8e9a27e688e9718cf50013 Mon Sep 17 00:00:00 2001 From: Oliver Tappe Date: Mon, 2 Jun 2008 22:30:19 +0000 Subject: Implemented a better algorithm for keeping the plugins and the references to them (and their attributes) in the DB in sync: * The DB now keeps a hash-value for the list of known plugins and their attributes and checks this value against the current one on every connect. If the values do not match, the DB is brought up-to-date automatically (i.e. the attributes are synchronized with the systems, clients and groups). git-svn-id: http://svn.openslx.org/svn/openslx/openslx/trunk@1837 95ad53e4-c205-0410-b2fa-d234c58c8868 --- config-db/OpenSLX/ConfigDB.pm | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'config-db/OpenSLX/ConfigDB.pm') diff --git a/config-db/OpenSLX/ConfigDB.pm b/config-db/OpenSLX/ConfigDB.pm index 1d9c6a36..37bc1404 100644 --- a/config-db/OpenSLX/ConfigDB.pm +++ b/config-db/OpenSLX/ConfigDB.pm @@ -151,9 +151,8 @@ The precise name of the database that should be connected (defaults to 'openslx' sub connect ## no critic (ProhibitBuiltinHomonyms) { my $self = shift; - my $dbParams = shift; - # hash-ref with any additional info that might be required by - # specific metadb-module (not used yet) + my $dbParams = shift; # hash-ref with any additional info that might be + # required by specific metadb-module (not used yet) my $dbType = $openslxConfig{'db-type'}; # name of underlying database module... @@ -191,6 +190,17 @@ sub connect ## no critic (ProhibitBuiltinHomonyms) $self->{'db-schema'}->checkAndUpgradeDBSchemaIfNecessary($self) or die _tr('unable to check/update DB schema!'); + # check if any plugins (or plugin-attributes) have been added/removed since + # last DB-session and bring the DB up-to-date, if so + my $pluginInfoHashVal + = OpenSLX::OSPlugin::Roster->computeMD5HashOverAvailablePlugins(); + my $pluginInfoHashValInDB = $metaDB->schemaFetchPluginInfoHashVal(); + vlog(1, "plugin-info-hashes: $pluginInfoHashVal <=> $pluginInfoHashValInDB"); + if ($pluginInfoHashValInDB ne $pluginInfoHashVal) { + $self->cleanupAnyInconsistencies(); + return if !$metaDB->schemaSetPluginInfoHashVal($pluginInfoHashVal); + } + return 1; } @@ -1285,9 +1295,6 @@ sub addInstalledPlugin my $pluginName = shift; my $pluginAttrs = shift || {}; - # make sure the attributes of this plugin are available via default system - $self->synchronizeAttributesWithDB(); - return $self->{'meta-db'}->addInstalledPlugin( $vendorOSID, $pluginName, $pluginAttrs ); -- cgit v1.2.3-55-g7522