diff --git a/src/dashboard.py b/src/dashboard.py index 66aa969..1cfbf71 100644 --- a/src/dashboard.py +++ b/src/dashboard.py @@ -403,13 +403,9 @@ class PeerShareLinks: # print(self.Links) def __getSharedLinks(self): self.Links.clear() - try: - allLinks = sqlSelect("SELECT * FROM PeerShareLinks WHERE ExpireDate IS NULL OR ExpireDate > datetime('now', 'localtime')").fetchall() - for link in allLinks: - self.Links.append(PeerShareLink(*link)) - # temo fix for https://github.com/donaldzou/WGDashboard/issues/432 - except sqlite3.DatabaseError as e: - print(f"Database error occurred: {e}") + allLinks = sqlSelect("SELECT * FROM PeerShareLinks WHERE ExpireDate IS NULL OR ExpireDate > datetime('now', 'localtime')").fetchall() + for link in allLinks: + self.Links.append(PeerShareLink(*link)) def getLink(self, Configuration: str, Peer: str) -> list[PeerShareLink]: self.__getSharedLinks() @@ -1427,8 +1423,13 @@ cursor = sqldb.cursor() def sqlSelect(statement: str, paramters: tuple = ()) -> sqlite3.Cursor: with sqldb: - cursor = sqldb.cursor() - return cursor.execute(statement, paramters) + try: + cursor = sqldb.cursor() + return cursor.execute(statement, paramters) + # temo fix for https://github.com/donaldzou/WGDashboard/issues/432 + except sqlite3.DatabaseError as e: + print(f"Database error occurred: {e}") + return [] def sqlUpdate(statement: str, paramters: tuple = ()) -> sqlite3.Cursor: with sqldb: