mirror of
https://github.com/donaldzou/WGDashboard.git
synced 2026-04-03 03:16:18 +00:00
v4.3.1 bug fix (#1149)
* Fix bugs * Fixes and improvements * Update comment * Reduce comment
This commit is contained in:
@@ -601,12 +601,19 @@ def API_deleteWireguardConfigurationBackup():
|
|||||||
|
|
||||||
@app.get(f'{APP_PREFIX}/api/downloadWireguardConfigurationBackup')
|
@app.get(f'{APP_PREFIX}/api/downloadWireguardConfigurationBackup')
|
||||||
def API_downloadWireguardConfigurationBackup():
|
def API_downloadWireguardConfigurationBackup():
|
||||||
configurationName = request.args.get('configurationName')
|
configurationName = os.path.basename(request.args.get('configurationName'))
|
||||||
backupFileName = request.args.get('backupFileName')
|
backupFileName = os.path.basename(request.args.get('backupFileName'))
|
||||||
|
|
||||||
if configurationName is None or configurationName not in WireguardConfigurations.keys():
|
if configurationName is None or configurationName not in WireguardConfigurations.keys():
|
||||||
return ResponseObject(False, "Configuration does not exist", status_code=404)
|
return ResponseObject(False, "Configuration does not exist", status_code=404)
|
||||||
|
|
||||||
status, zip = WireguardConfigurations[configurationName].downloadBackup(backupFileName)
|
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')
|
@app.post(f'{APP_PREFIX}/api/restoreWireguardConfigurationBackup')
|
||||||
def API_restoreWireguardConfigurationBackup():
|
def API_restoreWireguardConfigurationBackup():
|
||||||
@@ -1207,20 +1214,6 @@ def API_getPeerScheduleJobLogs(configName):
|
|||||||
requestAll = True
|
requestAll = True
|
||||||
return ResponseObject(data=AllPeerJobs.getPeerJobLogs(configName))
|
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
|
Tools
|
||||||
'''
|
'''
|
||||||
|
|||||||
@@ -46,14 +46,7 @@ const restoreBackup = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const downloadBackup = () => {
|
const downloadBackup = () => {
|
||||||
fetchGet("/api/downloadWireguardConfigurationBackup", {
|
window.location.href = getUrl(`/api/downloadWireguardConfigurationBackup?configurationName=${route.params.id}&backupFileName=${props.b.filename}`);
|
||||||
configurationName: route.params.id,
|
|
||||||
backupFileName: props.b.filename
|
|
||||||
}, (res) => {
|
|
||||||
if (res.status){
|
|
||||||
window.open(getUrl(`/fileDownload?file=${res.data}`), '_blank')
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const delaySeconds = computed(() => {
|
const delaySeconds = computed(() => {
|
||||||
|
|||||||
Reference in New Issue
Block a user