Skip to content

Commit 65cee1b

Browse files
committed
Fixes the problem
Essentially when merging property lists, should only take the old data when setting the channel to be inactive. Otherwise only the new data owned by the recceiver is relevant
1 parent f6584ec commit 65cee1b

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

server/recceiver/cfstore.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -273,8 +273,6 @@ def _commitWithThread(self, transaction):
273273
)
274274
continue
275275
recordInfoByName[info["pvName"]] = info
276-
_log.debug("Add record: {record_id}: {info}".format(record_id=record_id, info=info))
277-
_log.debug("Add record: {record_id}: {info}".format(record_id=record_id, info=info))
278276

279277
if transaction.initial:
280278
"""Add IOC to source list """
@@ -538,6 +536,7 @@ def __updateCF__(
538536
create_time_property(owner, iocTime),
539537
],
540538
cf_channel,
539+
use_old=True,
541540
)
542541
channels.append(cf_channel)
543542
_log.debug("Add orphaned channel with no IOC: {s}".format(s=channels[-1]))
@@ -551,6 +550,7 @@ def __updateCF__(
551550
create_time_property(owner, iocTime),
552551
],
553552
alias,
553+
use_old=True,
554554
)
555555
channels.append(alias)
556556
_log.debug("Add orphaned alias with no IOC: {s}".format(s=channels[-1]))
@@ -560,13 +560,20 @@ def __updateCF__(
560560
Channel exists in Channelfinder with same hostname and iocname.
561561
Update the status to ensure it is marked active and update the time.
562562
"""
563+
_log.debug(
564+
"Channel {s} exists in Channelfinder with same hostname and iocname".format(
565+
s=cf_channel["name"]
566+
)
567+
)
568+
_log.debug("Property list before: {s}".format(s=cf_channel["properties"]))
563569
cf_channel["properties"] = __merge_property_lists(
564570
[
565571
create_active_property(owner),
566572
create_time_property(owner, iocTime),
567573
],
568574
cf_channel,
569575
)
576+
_log.debug("Property list after: {s}".format(s=cf_channel["properties"]))
570577
channels.append(cf_channel)
571578
_log.debug("Add existing channel with same IOC: {s}".format(s=channels[-1]))
572579
new_channels.remove(cf_channel["name"])
@@ -710,15 +717,18 @@ def create_default_properties(owner, iocTime, recceiverid, channels_dict, iocs,
710717
)
711718

712719

713-
def __merge_property_lists(newProperties: list[dict[str, str]], channel: dict[str, list[dict[str, str]]]):
720+
def __merge_property_lists(
721+
newProperties: list[dict[str, str]], channel: dict[str, list[dict[str, str]]], use_old=False
722+
):
714723
"""
715724
Merges two lists of properties ensuring that there are no 2 properties with
716725
the same name In case of overlap between the new and old property lists the
717726
new property list wins out
718727
"""
719728
newPropNames = [p["name"] for p in newProperties]
729+
owner = channel["owner"]
720730
for oldProperty in channel["properties"]:
721-
if oldProperty["name"] not in newPropNames:
731+
if oldProperty["name"] not in newPropNames and (oldProperty["owner"] != owner or use_old):
722732
newProperties = newProperties + [oldProperty]
723733
return newProperties
724734

0 commit comments

Comments
 (0)