Fixed duplicated data

This commit is contained in:
Donald Zou
2025-10-24 09:53:40 +08:00
parent 9dd5341fd9
commit 10c9b5635f

View File

@@ -503,6 +503,15 @@ class WireguardConfiguration:
if tempPeer.status == "running": if tempPeer.status == "running":
endpoint = tempPeer.endpoint.rsplit(":", 1) endpoint = tempPeer.endpoint.rsplit(":", 1)
if len(endpoint) == 2 and len(endpoint[0]) > 0: if len(endpoint) == 2 and len(endpoint[0]) > 0:
exist = conn.execute(
self.peersHistoryEndpointTable.select().where(
sqlalchemy.and_(
self.peersHistoryEndpointTable.c.id == tempPeer.id,
self.peersHistoryEndpointTable.c.endpoint == endpoint[0]
)
)
).mappings().fetchone()
if not exist:
conn.execute( conn.execute(
self.peersHistoryEndpointTable.insert().values({ self.peersHistoryEndpointTable.insert().values({
"id": tempPeer.id, "id": tempPeer.id,