From 18531b71c774e25ee6991c7ac3149f06a57e7ab9 Mon Sep 17 00:00:00 2001 From: Donald Zou Date: Fri, 24 Oct 2025 08:47:02 +0800 Subject: [PATCH] Fixed schedule task delete issue --- src/dashboard.py | 2 +- src/modules/PeerJobs.py | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/dashboard.py b/src/dashboard.py index 223e9d5f..3dd1edeb 100644 --- a/src/dashboard.py +++ b/src/dashboard.py @@ -194,7 +194,7 @@ with app.app_context(): DashboardConfig = DashboardConfig() EmailSender = EmailSender(DashboardConfig) AllPeerShareLinks: PeerShareLinks = PeerShareLinks(DashboardConfig, WireguardConfigurations) - AllPeerJobs: PeerJobs = PeerJobs(DashboardConfig, WireguardConfigurations) + AllPeerJobs: PeerJobs = PeerJobs(DashboardConfig, WireguardConfigurations, AllPeerShareLinks) DashboardLogger: DashboardLogger = DashboardLogger() DashboardPlugins: DashboardPlugins = DashboardPlugins(app, WireguardConfigurations) DashboardWebHooks: DashboardWebHooks = DashboardWebHooks(DashboardConfig) diff --git a/src/modules/PeerJobs.py b/src/modules/PeerJobs.py index 694f6538..913cbe5f 100644 --- a/src/modules/PeerJobs.py +++ b/src/modules/PeerJobs.py @@ -9,7 +9,7 @@ from datetime import datetime from flask import current_app class PeerJobs: - def __init__(self, DashboardConfig, WireguardConfigurations): + def __init__(self, DashboardConfig, WireguardConfigurations, AllPeerShareLinks): self.Jobs: list[PeerJob] = [] self.engine = db.create_engine(ConnectionString('wgdashboard_job')) self.metadata = db.MetaData() @@ -28,6 +28,7 @@ class PeerJobs: self.__getJobs() self.JobLogger: PeerJobLogger = PeerJobLogger(self, DashboardConfig) self.WireguardConfigurations = WireguardConfigurations + self.AllPeerShareLinks = AllPeerShareLinks def __getJobs(self): self.Jobs.clear() @@ -162,7 +163,7 @@ class PeerJobs: if job.Action == "restrict": s, msg = c.restrictPeers([fp.id]) elif job.Action == "delete": - s, msg = c.deletePeers([fp.id]) + s, msg = c.deletePeers([fp.id], self, self.AllPeerShareLinks) elif job.Action == "reset_total_data_usage": s = fp.resetDataUsage("total") c.restrictPeers([fp.id]) @@ -179,12 +180,10 @@ class PeerJobs: f"Peer {fp.id} from {c.Name} failed {job.Action}ed." ) else: - current_app.logger.warning(f"Somehow can't find this peer {job.Peer} from {c.Name} failed {job.Action}ed.") self.JobLogger.log(job.JobID, False, f"Somehow can't find this peer {job.Peer} from {c.Name} failed {job.Action}ed." ) else: - current_app.logger.warning(f"Somehow can't find this peer {job.Peer} from {job.Configuration} failed {job.Action}ed.") self.JobLogger.log(job.JobID, False, f"Somehow can't find this peer {job.Peer} from {job.Configuration} failed {job.Action}ed." )