fix backup/restore of favourites, fix notify bug

git-svn-id: file:///root/webif/svn/pkg/webif/trunk@3521 2a923420-c742-0410-a762-8d5b09965624
This commit is contained in:
hummypkg 2017-01-12 14:36:41 +00:00
parent 5104dbd387
commit 8b021ec4b7
8 changed files with 115 additions and 55 deletions

View File

@ -1,10 +1,10 @@
Package: webif Package: webif
Priority: optional Priority: optional
Section: web Section: web
Version: 1.3.5-6 Version: 1.3.5-7
Architecture: mipsel Architecture: mipsel
Maintainer: af123@hpkg.tv Maintainer: af123@hpkg.tv
Depends: tcpfix,webif-channelicons(>=1.1.24),lighttpd(>=1.4.39-1),jim(>=0.77),jim-oo(>=0.77),jim-sqlite3(>=0.76),jim-cgi(>=0.7-1),jim-binary(>=0.76),service-control(>=2.3),busybox(>=1.20.2-1),lsof(>=4.87),epg(>=1.2.5),hmt(>=2.0.10),ssmtp,cron-daemon(>=1.18.3-3),at(>=3.1.18),anacron,trm(>=1.1),openssl-command,nicesplice,id3v2,file,rsvsync(>=1.1.9),webif-charts(>=1.2-1),stripts(>=1.2.5-3),tmenu(>=1.21-2),ffmpeg,id3v2,multienv(>=1.6),tcpping(>=1.1),e2fsprogs,wireless-tools(>=29-1),dbupdate,recmon(>=2.0.7),hwctl,nugget(>=0.95),sqlite3(>=3.15.1) Depends: tcpfix,webif-channelicons(>=1.1.24),lighttpd(>=1.4.39-1),jim(>=0.77),jim-oo(>=0.77),jim-sqlite3(>=0.76),jim-cgi(>=0.7-1),jim-binary(>=0.76),service-control(>=2.3),busybox(>=1.20.2-1),lsof(>=4.87),epg(>=1.2.5),hmt(>=2.0.10),ssmtp,cron-daemon(>=1.18.3-3),at(>=3.1.18),anacron,trm(>=1.1),openssl-command,nicesplice,id3v2,file,rsvsync(>=1.1.10),webif-charts(>=1.2-1),stripts(>=1.2.5-3),tmenu(>=1.21-2),ffmpeg,id3v2,multienv(>=1.6),tcpping(>=1.1),e2fsprogs,wireless-tools(>=29-1),dbupdate,recmon(>=2.0.7),hwctl,nugget(>=0.95),sqlite3(>=3.15.1)
Suggests: Suggests:
Description: An evolving web interface for the Humax. Description: An evolving web interface for the Humax.
Tags: http://hummy.tv/forum/threads/7619/ Tags: http://hummy.tv/forum/threads/7619/

View File

@ -38,15 +38,7 @@ EOM
$PKG_ROOT/etc/init.d/S02anacron start < /dev/null > /dev/null 2>&1 & $PKG_ROOT/etc/init.d/S02anacron start < /dev/null > /dev/null 2>&1 &
[ -f /tmp/webif_auto.log ] && rm -f /tmp/webif_auto.log [ -f /tmp/webif_auto.log ] && rm -f /tmp/webif_auto.log
[ -f /mod/webif/.strip-updated ] && rm -f /mod/webif/.strip-updated
#if [ ! -f /mod/webif/.strip-updated ]; then
# echo "*********************************"
# echo "* Please wait while any shrunk recordings are flagged..."
# echo "*********************************"
# /mod/webif/lib/bin/strip-update
#
# touch /mod/webif/.strip-updated
#fi
/mod/webif/lib/bin/diskattrs /mod/webif/lib/bin/diskattrs
/mod/webif/lib/auto/upgrade /mod/webif/lib/auto/upgrade

View File

@ -16,6 +16,7 @@ switch $runmode {
cli { cli {
set type "full" set type "full"
if {"-X" in $argv} { set schedtime 7200 } if {"-X" in $argv} { set schedtime 7200 }
if {"-x" in $argv} { set schedtime 7200 }
} }
} }

View File

@ -65,6 +65,8 @@ $('#restore_button').click(function() {
refresh_backup_files(); refresh_backup_files();
$('#restore_warning').slideDown(); $('#restore_warning').slideDown();
$('#restart_block').slideDown('slow'); $('#restart_block').slideDown('slow');
list_reload_required = true;
visual_reload_required = true;
}); });
}); });
} }

View File

@ -9,7 +9,7 @@ set dir /mod/var/backup
httpheader httpheader
set file [file tail [cgi_get restore_file]] set file [file tail [cgi_get restore_file test]]
if {$file == 0} { if {$file == 0} {
puts "No filename supplied." puts "No filename supplied."
exit exit
@ -32,16 +32,11 @@ puts "Listing scheduled events from <i>$file</i>..."
set fields [[rsv] cleanvars] set fields [[rsv] cleanvars]
set data [split [read $fd] "\n"] set data [split [read $fd] "\n"]
set ver 1 set ver 1
foreach line $data { proc event {vals} {
if {[string match "# version *" $line]} { global fields ver
set ver [lindex [split $line " "] 2]
puts "Backup version $ver"
}
set vals [split $line "\t"]
if {[lindex $vals 0] ne "event"} { continue }
set vars {} set vars {}
set i 0 set i 0
foreach f $fields { foreach f $fields {
@ -57,6 +52,48 @@ foreach line $data {
clock format [$rsv end] -format {%H:%M}])" clock format [$rsv end] -format {%H:%M}])"
} }
set favnames {}
proc fav {vals} {{lgroup 0}} {
global favnames
lassign $vals x group svctype svcname idx
if {$group != $lgroup} {
set lgroup $group
if {[dict exists $favnames $group]} {
puts "Favourites ($favnames($group))"
} else {
puts "Favourites (group $group)"
}
}
puts " $svcname"
}
proc favname {vals} {
global favnames
lassign $vals x num idx name
puts "Favourites $num '$name'"
set favnames($idx) $name
}
foreach line $data {
if {[string match "# version *" $line]} {
set ver [lindex [split $line " "] 2]
puts "Backup version $ver"
}
set vals [split $line "\t"]
set type [lindex $vals 0]
switch -- $type {
fav -
favname -
event { $type $vals }
#default { puts "Unhandled '$type'" }
}
}
close $fd close $fd
rsv cleanup rsv cleanup

View File

@ -18,6 +18,7 @@ set lines {}
set seen {} set seen {}
foreach line [split [file read /mod/tmp/notify.log] "\n"] { foreach line [split [file read /mod/tmp/notify.log] "\n"] {
set rest [lassign [split $line -] date] set rest [lassign [split $line -] date]
if {$rest eq ""} { set rest $date }
if {[dict exists $seen $rest]} { if {[dict exists $seen $rest]} {
incr seen($rest) incr seen($rest)
} else { } else {

View File

@ -52,10 +52,11 @@ foreach a {
} { } {
lassign $a id attr lassign $a id attr
if {![dict exists $attrs $id]} continue if {![dict exists $attrs $id]} continue
puts "$attr: $attrs($id)" puts -nonewline "$attr: $attrs($id) "
$settings _nval_setting "SMART_$attr" $attrs($id) $settings _nval_setting "SMART_$attr" $attrs($id)
if {$attrs($id) < [$settings _nval_setting "SMART_ack_$attr"]} { if {$attrs($id) < [$settings _nval_setting "SMART_ack_$attr"]} {
$settings _nval_setting "SMART_ack_$attr" $attrs($id) $settings _nval_setting "SMART_ack_$attr" $attrs($id)
} }
} }
puts ""

View File

@ -124,13 +124,7 @@ rsv method isseries {} {
} }
rsv method _strip {str} { rsv method _strip {str} {
if {[string range $str 1 2] eq "i7"} { return [system strip $str]
set str [string range $str 3 end]
}
if {[string first "\025" $str] == 0} {
set str [string range $str 1 end]
}
return $str
} }
rsv method folder {} { rsv method folder {} {
@ -799,6 +793,18 @@ proc {rsv backup} {file} {
puts "Done." puts "Done."
puts "Backing up channel favourites..." puts "Backing up channel favourites..."
puts " Names:"
# Favourite names
set favnames {}
loop i 1 6 {
set favname [system strip \
[system param FAV_CUSTOM_STR0$i Text]]
set idx [expr 1 << ($i - 1)]
set favnames($idx) $favname
puts $fd "favname\t$i\t$idx\t$favname"
puts " $favname"
}
set grp 0 set grp 0
foreach res [$rsvdb query { foreach res [$rsvdb query {
@ -811,7 +817,11 @@ proc {rsv backup} {file} {
}] { }] {
if {$res(eFavGroup) != $grp} { if {$res(eFavGroup) != $grp} {
set grp $res(eFavGroup) set grp $res(eFavGroup)
puts " Group $grp" if {[dict exists $favnames $grp]} {
puts " Group $favnames($grp)"
} else {
puts " Group '$grp':"
}
} }
puts " $res(szSvcName)" puts " $res(szSvcName)"
puts $fd "fav\t$res(eFavGroup)\t$res(eSvcType)\t$res(szSvcName)\t$res(favIdx)" puts $fd "fav\t$res(eFavGroup)\t$res(eSvcType)\t$res(szSvcName)\t$res(favIdx)"
@ -848,7 +858,7 @@ proc {rsv restore} {file} {
puts "Restoring scheduled events from <i>$file</i>..." puts "Restoring scheduled events from <i>$file</i>..."
$rsvdb query {begin transaction;} catch { exec /mod/bin/nugget quit }
$rsvdb query {delete from TBL_RESERVATION;} $rsvdb query {delete from TBL_RESERVATION;}
set fields [[rsv] cleanvars] set fields [[rsv] cleanvars]
@ -859,6 +869,7 @@ proc {rsv restore} {file} {
set hsvcmap {} set hsvcmap {}
set lcnmap {} set lcnmap {}
set favmap {}
# Check version, build maps for later. # Check version, build maps for later.
foreach line $data { foreach line $data {
@ -866,15 +877,18 @@ proc {rsv restore} {file} {
set ver [lindex [split $line " "] 2] set ver [lindex [split $line " "] 2]
puts "Backup version $ver" puts "Backup version $ver"
} }
lassign [split $line "\t"] tag hsvc name lassign [split $line "\t"] tag f1 f2 f3 f4
if {$tag eq "hsvc"} { switch -- $tag {
set hsvcmap($hsvc) $name hsvc { set hsvcmap($f1) $f2 }
} lcn { set lcnmap($f2) $f1 }
if {$tag eq "lcn"} { favname { set favmap($f2) $f3 }
set lcnmap($name) $hsvc
} }
} }
set chanmap [lreverse $hsvcmap]
# Restore events
foreach line $data { foreach line $data {
set vals [split $line "\t"] set vals [split $line "\t"]
if {[lindex $vals 0] ne "event"} continue if {[lindex $vals 0] ne "event"} continue
@ -949,62 +963,74 @@ proc {rsv restore} {file} {
} }
if {!$bad} { if {!$bad} {
if {[catch {$rsv insert pending 1} msg]} { if {[catch {$rsv insert pending 1 1} msg]} {
puts " Error inserting event, $msg" puts " Error inserting event, $msg"
} }
} }
puts "" puts ""
} }
$rsvdb query {commit transaction;}
puts "Restoring favourite channels..." puts "Restoring favourite channels..."
$rsvdb query {begin transaction;}
$rsvdb query {delete from channel.TBL_FAV} $rsvdb query {delete from channel.TBL_FAV}
$rsvdb query {drop table if exists pending.fav} $rsvdb query {drop table if exists pending.fav}
$rsvdb query {create table pending.fav ( $rsvdb query {create table pending.fav (
favIdx integer primary key autoincrement unique, favIdx integer primary key unique,
hSvc integer(4), hSvc integer(4),
eFavGroup integer(4), eFavGroup integer(4),
[eSvcType] integer(4) [eSvcType] integer(4)
)} )}
$rsvdb query {drop table if exists pending.favnames}
$rsvdb query {create table pending.favnames (
idx integer primary key unique,
name string
)}
set grp 0 set grp 0
foreach line $data { foreach line $data {
set vals [split $line "\t"] set vals [split $line "\t"]
if {[lindex $vals 0] eq "favname"} {
lassign $vals x num x name
$rsvdb query {
insert into
pending.favnames(idx, name)
values(%s, '%s')
} $num $name
continue
}
if {[lindex $vals 0] ne "fav"} { continue } if {[lindex $vals 0] ne "fav"} { continue }
set group [lindex $vals 1] lassign $vals x group type chan idx
set type [lindex $vals 2]
set chan [lindex $vals 3]
set idx [lindex $vals 4]
if {$idx eq ""} { set idx 0 } if {$idx eq ""} { set idx 0 }
set hsvc [get_channel_attr $chan]
if {$grp != $group} { if {$grp != $group} {
set grp $group set grp $group
puts " Group $grp" if {[dict exists $favmap $grp]} {
puts " Group $favmap($grp)"
} else {
puts " Group $grp"
}
} }
puts " $chan" puts " $chan"
if {$hsvc eq ""} { if {[dict exists $chanmap $chan]} {
set hsvc $chanmap($chan)
} else {
puts " Cannot map channel name to service." puts " Cannot map channel name to service."
continue continue
} }
set query " $rsvdb query {
insert into insert into
pending.fav(favIdx, hSvc, eFavGroup, eSvcType) pending.fav(favIdx, hSvc, eFavGroup, eSvcType)
values($idx, $hsvc, $group, $type); values(%s, %s, %s, %s);
" } $idx $hsvc $group $type
$rsvdb query $query
} }
$rsvdb query {commit transaction;}
system restartpending system restartpending
close $fd close $fd