mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-01-31 18:59:33 +00:00
configDB.pm: add lastReorg to info output
git-svn-id: https://svn.fhem.de/fhem/trunk@16957 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
7d2227ad56
commit
d7705d6e37
@ -136,6 +136,10 @@
|
|||||||
# check migration only if parameter migrate => 1
|
# check migration only if parameter migrate => 1
|
||||||
# is set in configDB.conf
|
# is set in configDB.conf
|
||||||
#
|
#
|
||||||
|
# 2018-07-04 - bugfix change rescue mode persistence
|
||||||
|
#
|
||||||
|
# 2018-07-07 - change lastReorg added to info output
|
||||||
|
#
|
||||||
##############################################################################
|
##############################################################################
|
||||||
=cut
|
=cut
|
||||||
|
|
||||||
@ -801,8 +805,7 @@ sub _cfgDB_ReadCfg(@) {
|
|||||||
my $count = $fhem_dbh->selectrow_array('SELECT count(*) FROM fhemversions');
|
my $count = $fhem_dbh->selectrow_array('SELECT count(*) FROM fhemversions');
|
||||||
$count--;
|
$count--;
|
||||||
$version = $version > $count ? $count : $version;
|
$version = $version > $count ? $count : $version;
|
||||||
Log 0, "configDB loading version $version on user request. ".
|
Log 0, "configDB loading version $version on user request.";
|
||||||
"Don't forget to unset variable cfgDB_version in environment!";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# maybe this will be done with join later
|
# maybe this will be done with join later
|
||||||
@ -939,6 +942,7 @@ sub _cfgDB_Info($) {
|
|||||||
my $maxVersions = $configDB{attr}{maxversions};
|
my $maxVersions = $configDB{attr}{maxversions};
|
||||||
$maxVersions = ($maxVersions) ? $maxVersions : 0;
|
$maxVersions = ($maxVersions) ? $maxVersions : 0;
|
||||||
push @r, " max Versions: $maxVersions" if($maxVersions);
|
push @r, " max Versions: $maxVersions" if($maxVersions);
|
||||||
|
push @r, " lastReorg: ".$configDB{attr}{'lastReorg'};
|
||||||
my $count;
|
my $count;
|
||||||
$count = $fhem_dbh->selectrow_array('SELECT count(*) FROM fhemconfig');
|
$count = $fhem_dbh->selectrow_array('SELECT count(*) FROM fhemconfig');
|
||||||
push @r, " config: $count entries";
|
push @r, " config: $count entries";
|
||||||
@ -1034,10 +1038,14 @@ sub _cfgDB_Reorg(;$$) {
|
|||||||
$lastversion = (defined($lastversion)) ? $lastversion : 3;
|
$lastversion = (defined($lastversion)) ? $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;
|
||||||
|
my $uuid = $fhem_dbh->selectrow_array("select versionuuid from fhemversions where version = 0");
|
||||||
$fhem_dbh->do("delete FROM fhemconfig where versionuuid in (select versionuuid from fhemversions where version > $lastversion)");
|
$fhem_dbh->do("delete FROM fhemconfig where versionuuid in (select versionuuid from fhemversions where version > $lastversion)");
|
||||||
$fhem_dbh->do("delete from fhemversions where version > $lastversion");
|
$fhem_dbh->do("delete from fhemversions where version > $lastversion");
|
||||||
$fhem_dbh->do("delete FROM fhemconfig where versionuuid in (select versionuuid from fhemversions where version = -1)");
|
$fhem_dbh->do("delete FROM fhemconfig where versionuuid in (select versionuuid from fhemversions where version = -1)");
|
||||||
$fhem_dbh->do("delete from fhemversions where version = -1");
|
$fhem_dbh->do("delete from fhemversions where version = -1");
|
||||||
|
my $ts = localtime(time);
|
||||||
|
$configDB{attr}{'lastReorg'} = $ts;
|
||||||
|
_cfgDB_InsertLine($fhem_dbh,$uuid,"attr configdb lastReorg $ts",-1);
|
||||||
$fhem_dbh->commit();
|
$fhem_dbh->commit();
|
||||||
$fhem_dbh->disconnect();
|
$fhem_dbh->disconnect();
|
||||||
eval qx(sqlite3 $cfgDB_filename vacuum) if($cfgDB_dbtype eq "SQLITE");
|
eval qx(sqlite3 $cfgDB_filename vacuum) if($cfgDB_dbtype eq "SQLITE");
|
||||||
|
Loading…
Reference in New Issue
Block a user