diff --git a/var/mongoose/cgi-bin/backup/backup.js b/var/mongoose/cgi-bin/backup/backup.js index 9cf8dc0c..23802616 100755 --- a/var/mongoose/cgi-bin/backup/backup.js +++ b/var/mongoose/cgi-bin/backup/backup.js @@ -39,11 +39,11 @@ $(document).ready(function() { } }); $('#restore_button').click(function() { - $('#restore_working').slideDown(); var backup = $('input.restore').val(); if (confirm('Are you sure you wish to erase all scheduled ' + 'recordings and restore ' + backup + '?')) { + $('#restore_working').slideDown(); $('#results').load('/cgi-bin/backup/restore.jim?' + $('input.restore').serialize(), function() { $('#results').slideDown(function() { diff --git a/var/mongoose/cgi-bin/backup/restore.jim b/var/mongoose/cgi-bin/backup/restore.jim index c9f0e3a5..6f142dcb 100755 --- a/var/mongoose/cgi-bin/backup/restore.jim +++ b/var/mongoose/cgi-bin/backup/restore.jim @@ -33,6 +33,24 @@ if {[catch { set fd [open $ffile r] } msg]} { exit } +proc findhsvc {channel} { + global rsvdb + + set hsvc [$rsvdb query " + select hSvc + from channel.TBL_SVC + where szSvcName = '$channel' + or szSvcame = '\025$channel' + limit 1 + "] + + if {[llength $hsvc] == 1} { + return [lindex [lindex $hsvc 0] 1] + } else { + return 0 + } +} + puts "Restoring scheduled events..." set fields [lsort [[rsv] vars]] @@ -59,24 +77,16 @@ foreach line [split [read $fd] "\n"] { # First, the service number set ohsvc [$rsv get hsvc] if {$ohsvc > 0} { - set hsvc [$rsvdb query " - select hSvc - from channel.TBL_SVC - where szSvcName = '[$rsv get szSvcName]' - limit 1 - "] - if {[llength $hsvc] != 1} { + set hsvc [findhsvc [$rsv get szSvcName]] + if {$hsvc == 0} { puts " Cannot find channel, restore failed." set bad 1 + } elseif {$hsvc != $ohsvc} { + puts -nonewline " Service number has " + puts "changed $ohsvc -> $hsvc, fixing." + $rsv set_hsvc $hsvc } else { - set hsvc [lindex [lindex $hsvc 0] 1] - if {$hsvc != $ohsvc} { - puts -nonewline " Service number has " - puts "changed $ohsvc -> $hsvc, fixing." - $rsv set_hsvc $hsvc - } else { - puts " No change in channel service." - } + puts " No change in channel service." } } } diff --git a/var/mongoose/include/diskspace.jim b/var/mongoose/include/diskspace.jim index 11543009..6efdf944 100755 --- a/var/mongoose/include/diskspace.jim +++ b/var/mongoose/include/diskspace.jim @@ -19,7 +19,7 @@ if {[os.gethostname] eq "hosting"} { set file [format "%02d" [expr {$perc * 25 / 100 + 1}]] puts "