mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-05-04 22:19:38 +00:00
configDB - code improvement
git-svn-id: https://svn.fhem.de/fhem/trunk/fhem@5696 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
c6b545e9aa
commit
ab1932b74f
@ -101,6 +101,7 @@ sub _cfgDB_Rotate($);
|
|||||||
sub _cfgDB_Uuid;
|
sub _cfgDB_Uuid;
|
||||||
sub _cfgDB_Info;
|
sub _cfgDB_Info;
|
||||||
sub _cfgDB_Filelist(;$);
|
sub _cfgDB_Filelist(;$);
|
||||||
|
sub _cfgDB_Reorg(;$$);
|
||||||
|
|
||||||
##################################################
|
##################################################
|
||||||
# Read configuration file for DB connection
|
# Read configuration file for DB connection
|
||||||
@ -330,6 +331,8 @@ if($cfgDB_dbconn =~ m/pg:/i) {
|
|||||||
foreach (@rowList) { _cfgDB_InsertLine($fhem_dbh, $uuid, $_); }
|
foreach (@rowList) { _cfgDB_InsertLine($fhem_dbh, $uuid, $_); }
|
||||||
$fhem_dbh->commit();
|
$fhem_dbh->commit();
|
||||||
$fhem_dbh->disconnect();
|
$fhem_dbh->disconnect();
|
||||||
|
my $maxVersions = AttrVal('configdb','maxversions',0);
|
||||||
|
_cfgDB_Reorg($maxVersions,1) if($maxVersions);
|
||||||
return 'configDB saved.';
|
return 'configDB saved.';
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -667,8 +670,8 @@ sub _cfgDB_Recover($) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# delete old configurations
|
# delete old configurations
|
||||||
sub _cfgDB_Reorg(;$) {
|
sub _cfgDB_Reorg(;$$) {
|
||||||
my ($lastversion) = @_;
|
my ($lastversion,$quiet) = @_;
|
||||||
$lastversion = ($lastversion > 0) ? $lastversion : 3;
|
$lastversion = ($lastversion > 0) ? $lastversion : 3;
|
||||||
Log3('configDB', 4, "DB Reorg started, keeping last $lastversion versions.");
|
Log3('configDB', 4, "DB Reorg started, keeping last $lastversion versions.");
|
||||||
my $fhem_dbh = _cfgDB_Connect;
|
my $fhem_dbh = _cfgDB_Connect;
|
||||||
@ -676,6 +679,7 @@ sub _cfgDB_Reorg(;$) {
|
|||||||
$fhem_dbh->do("delete from fhemversions where version > $lastversion");
|
$fhem_dbh->do("delete from fhemversions where version > $lastversion");
|
||||||
$fhem_dbh->commit();
|
$fhem_dbh->commit();
|
||||||
$fhem_dbh->disconnect();
|
$fhem_dbh->disconnect();
|
||||||
|
return if(defined($quiet));
|
||||||
return " Result after database reorg:\n"._cfgDB_Info;
|
return " Result after database reorg:\n"._cfgDB_Info;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user