v4.3.1 bug fix (#1149)

* Fix bugs

* Fixes and improvements

* Update comment

* Reduce comment
This commit is contained in:
mahemium
2026-02-26 11:15:52 +00:00
committed by Donald Zou
parent 2cdc0265b8
commit 468d1c7642
2 changed files with 11 additions and 25 deletions

View File

@@ -601,12 +601,19 @@ def API_deleteWireguardConfigurationBackup():
@app.get(f'{APP_PREFIX}/api/downloadWireguardConfigurationBackup')
def API_downloadWireguardConfigurationBackup():
configurationName = request.args.get('configurationName')
backupFileName = request.args.get('backupFileName')
configurationName = os.path.basename(request.args.get('configurationName'))
backupFileName = os.path.basename(request.args.get('backupFileName'))
if configurationName is None or configurationName not in WireguardConfigurations.keys():
return ResponseObject(False, "Configuration does not exist", status_code=404)
status, zip = WireguardConfigurations[configurationName].downloadBackup(backupFileName)
return ResponseObject(status, data=zip, status_code=(200 if status else 404))
if not status:
current_app.logger.error(f"Failed to download a requested backup.\nConfiguration Name: {configurationName}\nBackup File Name: {backupFileName}")
return ResponseObject(False, "Internal server error", status_code=500)
return send_file(os.path.join('download', zip), as_attachment=True)
@app.post(f'{APP_PREFIX}/api/restoreWireguardConfigurationBackup')
def API_restoreWireguardConfigurationBackup():
@@ -1207,20 +1214,6 @@ def API_getPeerScheduleJobLogs(configName):
requestAll = True
return ResponseObject(data=AllPeerJobs.getPeerJobLogs(configName))
'''
File Download
'''
@app.get(f'{APP_PREFIX}/fileDownload')
def API_download():
file = request.args.get('file')
if file is None or len(file) == 0:
return ResponseObject(False, "Please specify a file")
if os.path.exists(os.path.join('download', file)):
return send_file(os.path.join('download', file), as_attachment=True)
else:
return ResponseObject(False, "File does not exist")
'''
Tools
'''

View File

@@ -46,14 +46,7 @@ const restoreBackup = () => {
}
const downloadBackup = () => {
fetchGet("/api/downloadWireguardConfigurationBackup", {
configurationName: route.params.id,
backupFileName: props.b.filename
}, (res) => {
if (res.status){
window.open(getUrl(`/fileDownload?file=${res.data}`), '_blank')
}
})
window.location.href = getUrl(`/api/downloadWireguardConfigurationBackup?configurationName=${route.params.id}&backupFileName=${props.b.filename}`);
}
const delaySeconds = computed(() => {