From dd26628ea000375b495a0ae716307e03c377385d Mon Sep 17 00:00:00 2001 From: Jan Schneider Date: Tue, 27 Feb 2018 20:57:18 +0100 Subject: [PATCH] Delete downloaded firmware image after installation. --- addon/lib/rmupdate.tcl | 6 +++++- addon/www/index.html | 10 +++++++++- addon/www/rest.cgi | 13 +++++++++++-- 3 files changed, 25 insertions(+), 4 deletions(-) diff --git a/addon/lib/rmupdate.tcl b/addon/lib/rmupdate.tcl index 6f9eb86..bec0954 100644 --- a/addon/lib/rmupdate.tcl +++ b/addon/lib/rmupdate.tcl @@ -1113,7 +1113,7 @@ proc ::rmupdate::delete_firmware_image {version} { catch { eval {file delete [glob "${img_dir}/*${version}*.zip"]} } } -proc ::rmupdate::install_firmware_version {version lang {reboot 1} {dryrun 0}} { +proc ::rmupdate::install_firmware_version {version lang {reboot 1} {keep_download 0} {dryrun 0}} { variable language set language $lang if {[get_running_installation] != ""} { @@ -1142,6 +1142,10 @@ proc ::rmupdate::install_firmware_version {version lang {reboot 1} {dryrun 0}} { check_sizes $firmware_image update_filesystems $firmware_image $dryrun + if {!$keep_download && !$dryrun} { + file delete $firmware_image + } + set_running_installation "" if {$reboot && !$dryrun} { diff --git a/addon/www/index.html b/addon/www/index.html index bfd68ef..86cb19f 100644 --- a/addon/www/index.html +++ b/addon/www/index.html @@ -217,9 +217,10 @@ along with this program. If not, see . $('#modal-log').modal('show'); if (!running_installation) { var reboot = $('#reboot-after-install').is(':checked'); + var keep_download = ! $('#delete-download-after-install').is(':checked'); var dryrun = $('#dryrun').is(':checked'); set_running_installation("Firmware " + version); - rest("POST", "/start_install_firmware", JSON.stringify({"language": language, "version":version, "reboot":reboot, "dryrun":dryrun}), + rest("POST", "/start_install_firmware", JSON.stringify({"language": language, "version":version, "reboot":reboot, "dryrun":dryrun, "keep_download": keep_download}), function(data) { // We are not expecting a response }, @@ -580,6 +581,7 @@ along with this program. If not, see . installation_log: 'Installation log', open_release_info: 'Open release info', perform_trial_run: 'Perform a trial run with no changes made', + delete_download_after_install: 'Delete download after installation', reboot_after_install: 'Reboot system after installation', addons: 'Addons', addon_name: 'Addon name', @@ -648,6 +650,7 @@ along with this program. If not, see . installation_log: 'Installations-Protokoll', open_release_info: 'Release-Informationen öffnen', perform_trial_run: 'Testlauf durchführen ohne Änderungen durchzuführen', + delete_download_after_install: 'Download nach Installation löschen', reboot_after_install: 'System nach Installation neu starten', addons: 'Zusatzsoftware', addon_name: 'Name des Addons', @@ -811,6 +814,11 @@ along with this program. If not, see .
+
+ + +
+
diff --git a/addon/www/rest.cgi b/addon/www/rest.cgi index 32f2877..1d49339 100644 --- a/addon/www/rest.cgi +++ b/addon/www/rest.cgi @@ -70,6 +70,7 @@ proc process {} { regexp {\"language\"\s*:\s*\"([^\"]+)\"} $data match lang regexp {\"reboot\"\s*:\s*(true|false)} $data match reboot regexp {\"dryrun\"\s*:\s*(true|false)} $data match dryrun + regexp {\"keep_download\"\s*:\s*(true|false)} $data match keep_download if { [info exists version] && $version != "" } { if { ![info exists reboot] } { set reboot "true" @@ -79,7 +80,7 @@ proc process {} { } else { set reboot 0 } - if { ![info exists reboot] } { + if { ![info exists dryrun] } { set dryrun "false" } if {$dryrun == "true"} { @@ -87,7 +88,15 @@ proc process {} { } else { set dryrun 0 } - return "\"[rmupdate::install_firmware_version $version $lang $reboot $dryrun]\"" + if { ![info exists keep_download] } { + set keep_download "false" + } + if {$keep_download == "true"} { + set keep_download 1 + } else { + set keep_download 0 + } + return "\"[rmupdate::install_firmware_version $version $lang $reboot $keep_download $dryrun]\"" } else { error "Invalid version: ${data}" }