mirror of
https://github.com/donaldzou/WGDashboard.git
synced 2026-10-30 01:12:07 +00:00
Fix: backup regex, SQL cleanup, and restore metadata conflict (#1324)
* fix: backup filename regex dot escaping * fix: delete paired .sql file when removing backup * fix: restore backup metadata conflict
This commit is contained in:
@@ -315,7 +315,8 @@ class WireguardConfiguration:
|
|||||||
f'{dbName}_history_endpoint', self.metadata,
|
f'{dbName}_history_endpoint', self.metadata,
|
||||||
sqlalchemy.Column('id', sqlalchemy.String(255), nullable=False),
|
sqlalchemy.Column('id', sqlalchemy.String(255), nullable=False),
|
||||||
sqlalchemy.Column('endpoint', 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(
|
self.infoTable = sqlalchemy.Table(
|
||||||
@@ -949,8 +950,8 @@ class WireguardConfiguration:
|
|||||||
files.sort(key=lambda x: x[1], reverse=True)
|
files.sort(key=lambda x: x[1], reverse=True)
|
||||||
|
|
||||||
for f, ct in files:
|
for f, ct in files:
|
||||||
if RegexMatch(rf"^({self.Name})_(\d+)\\.(conf)$", f):
|
if RegexMatch(rf"^({self.Name})_(\d+)\.(conf)$", f):
|
||||||
s = re.search(rf"^({self.Name})_(\d+)\\.(conf)$", f)
|
s = re.search(rf"^({self.Name})_(\d+)\.(conf)$", f)
|
||||||
date = s.group(2)
|
date = s.group(2)
|
||||||
d = {
|
d = {
|
||||||
"filename": f,
|
"filename": f,
|
||||||
@@ -991,7 +992,11 @@ class WireguardConfiguration:
|
|||||||
if backupFileName not in backups:
|
if backupFileName not in backups:
|
||||||
return False
|
return False
|
||||||
try:
|
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:
|
except Exception as e:
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|||||||
Reference in New Issue
Block a user