Fix: backup regex, SQL cleanup, and restore metadata conflict (#1324)
Docker Build and Push / docker_build (push) Canceled after 0s
Docker Build and Push / docker_scan (push) Canceled after 0s

* fix: backup filename regex dot escaping

* fix: delete paired .sql file when removing backup

* fix: restore backup metadata conflict
This commit is contained in:
LEE Kai-Ze
2026-10-28 15:01:42 +01:00
committed by GitHub
parent c4cbbdb51b
commit e6f6201d25
+9 -4
View File
@@ -315,7 +315,8 @@ class WireguardConfiguration:
f'{dbName}_history_endpoint', self.metadata,
sqlalchemy.Column('id', sqlalchemy.String(255), nullable=False),
sqlalchemy.Column('endpoint', sqlalchemy.String(255), nullable=False),
sqlalchemy.Column('time', time_col_type)
sqlalchemy.Column('time', time_col_type),
extend_existing=True
)
self.infoTable = sqlalchemy.Table(
@@ -949,8 +950,8 @@ class WireguardConfiguration:
files.sort(key=lambda x: x[1], reverse=True)
for f, ct in files:
if RegexMatch(rf"^({self.Name})_(\d+)\\.(conf)$", f):
s = re.search(rf"^({self.Name})_(\d+)\\.(conf)$", f)
if RegexMatch(rf"^({self.Name})_(\d+)\.(conf)$", f):
s = re.search(rf"^({self.Name})_(\d+)\.(conf)$", f)
date = s.group(2)
d = {
"filename": f,
@@ -991,7 +992,11 @@ class WireguardConfiguration:
if backupFileName not in backups:
return False
try:
os.remove(os.path.join(self.__getProtocolPath(), 'WGDashboard_Backup', backupFileName))
backupPath = os.path.join(self.__getProtocolPath(), 'WGDashboard_Backup')
for ext in ('.conf', '.sql'):
f = os.path.join(backupPath, os.path.splitext(backupFileName)[0] + ext)
if os.path.exists(f):
os.remove(f)
except Exception as e:
return False
return True