2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-04-16 16:56:04 +00:00

fhem.pl: cache the uniqueID (Forum #108512)

git-svn-id: https://svn.fhem.de/fhem/trunk@21215 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
rudolfkoenig 2020-02-17 18:49:08 +00:00
parent 578b5834b3
commit 7604036dfb

View File

@ -303,6 +303,7 @@ my @cmdList; # Remaining commands in a chain. Used by sleep
my %sleepers; # list of sleepers
my %delayedShutdowns; # definitions needing delayed shutdown
my %fuuidHash; # for duplicate checking
my $globalUniqueID; # cache it
$init_done = 0;
$lastDefChange = 0;
@ -5435,13 +5436,18 @@ FileDelete($)
sub
getUniqueId()
{
return $globalUniqueID if($globalUniqueID);
my ($err, $uniqueID) = getKeyValue("uniqueID");
if(defined($uniqueID)) {
$uniqueID =~ s/[^0-9a-f]//g;
return $uniqueID if($uniqueID && length($uniqueID) == 32);
if($uniqueID && length($uniqueID) == 32) {
$globalUniqueID = $uniqueID;
return $uniqueID;
}
}
$uniqueID = createUniqueId();
setKeyValue("uniqueID", $uniqueID);
$globalUniqueID = $uniqueID;
return $uniqueID;
}