From 5639be67132918cdb4542134ba7cb0414e0e563d Mon Sep 17 00:00:00 2001 From: dami Date: Sat, 24 May 2025 18:48:57 +0800 Subject: [PATCH] Update monitor.py --- web/utils/system/monitor.py | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/web/utils/system/monitor.py b/web/utils/system/monitor.py index 801aaabfe..1a2090a60 100644 --- a/web/utils/system/monitor.py +++ b/web/utils/system/monitor.py @@ -51,12 +51,23 @@ class monitor: return True def initDBFile(self): - if os.path.exists(self._dbfile): - return True + is_reload = False sql_file = mw.getPanelDir() + '/web/admin/setup/sql/system.sql' + sql_file_md5 = mw.getPanelDir() + '/web/admin/setup/sql/system.md5' + content = mw.readFile(sql_file) + content_md5 = mw.md5(content) + if not os.path.exists(sql_file_md5): + mw.writeFile(sql_file_md5, content_md5) + + content_src_md5 = mw.readFile(sql_file) + if content_md5 != content_src_md5: + is_reload = True + + if os.path.exists(self._dbfile) and not is_reload: + return True + sql = db.Sql().dbPos(mw.getPanelDataDir(),'system') - csql = mw.readFile(sql_file) - csql_list = csql.split(';') + csql_list = content.split(';') for index in range(len(csql_list)): sql.execute(csql_list[index], ()) return True