Fixed the issue where Job and Share link is not delete when peer deleted

This commit is contained in:
Donald Zou
2025-08-20 14:15:03 +08:00
parent c5b72cb6d8
commit eab2c9d358
2 changed files with 6 additions and 2 deletions

View File

@@ -596,7 +596,7 @@ class WireguardConfiguration:
return False, f"Restricted {numOfRestrictedPeers} peer(s) successfully. Failed to restrict {numOfFailedToRestrictPeers} peer(s)"
def deletePeers(self, listOfPublicKeys) -> tuple[bool, str]:
def deletePeers(self, listOfPublicKeys, AllPeerJobs: PeerJobs, AllPeerShareLinks: PeerShareLinks) -> tuple[bool, str]:
numOfDeletedPeers = 0
numOfFailedToDeletePeers = 0
if not self.getStatus():
@@ -604,6 +604,10 @@ class WireguardConfiguration:
with self.engine.begin() as conn:
for p in listOfPublicKeys:
found, pf = self.searchPeer(p)
for job in pf.jobs:
AllPeerJobs.deleteJob(job)
for shareLink in pf.ShareLink:
AllPeerShareLinks.updateLinkExpireDate(shareLink.ShareID, datetime.now())
if found:
try:
subprocess.check_output(f"{self.Protocol} set {self.Name} peer {pf.id} remove",