From 5f473c9e723991e844a8e945fa7cc917e42bc6de Mon Sep 17 00:00:00 2001 From: hummypkg Date: Thu, 3 Apr 2014 20:21:40 +0000 Subject: [PATCH] add ts iterate git-svn-id: file:///root/webif/svn/humax/pkg/src/webif/trunk@1833 2a923420-c742-0410-a762-8d5b09965624 --- CONTROL/control | 2 +- var/mongoose/lib/bin/strip-update | 34 +++---------------------------- var/mongoose/lib/ts.class | 25 +++++++++++++++++++++++ 3 files changed, 29 insertions(+), 32 deletions(-) diff --git a/CONTROL/control b/CONTROL/control index 87774279..3fcb9d49 100644 --- a/CONTROL/control +++ b/CONTROL/control @@ -1,7 +1,7 @@ Package: webif Priority: optional Section: web -Version: 1.0.10-5 +Version: 1.0.10-6 Architecture: mipsel Maintainer: af123@hummypkg.org.uk Depends: webif-channelicons(>=1.1.10),mongoose(>=3.0.11),jim(>=0.75-1),jim-oo,jim-sqlite3(>=0.75),jim-cgi(>=0.7),jim-binary(>=0.75),service-control(>=1.2),busybox(>=1.20.2-1),lsof,epg(>=1.0.13),hmt(>=1.1.14),ssmtp,anacron,trm(>=1.1),openssl-command,nicesplice,id3v2,file,rsvsync(>=1.0.2),webif-charts(>=1.2),stripts(>=1.2.5-3),smartmontools,tmenu(>=1.05),ffmpeg,id3v2,multienv(>=1.6) diff --git a/var/mongoose/lib/bin/strip-update b/var/mongoose/lib/bin/strip-update index 0b431918..c1d87683 100755 --- a/var/mongoose/lib/bin/strip-update +++ b/var/mongoose/lib/bin/strip-update @@ -3,7 +3,8 @@ source /mod/webif/lib/setup require system.class ts.class -proc do_shrink {ts} { +ts iterate [lambda {ts} { + #puts " [$ts get file]" if {[$ts flag "Shrunk"]} { return } set file [file rootname [$ts get file]] @@ -26,34 +27,5 @@ proc do_shrink {ts} { puts " Flagging $file as shrunk..." $ts set_shrunk } -} - -proc entries {dir callback} { - foreach entry [readdir -nocomplain $dir] { - if {![string match {*.ts} $entry} continue - if {[catch {set ts [ts fetch "$dir/$entry"]}]} continue - if {$ts == 0} continue - $callback $ts - } -} - -proc scan {dir} { - puts "Scanning $dir..." - file stat "$dir/" st - if {$st(dev) != $::rootdev} { return } - - entries $dir do_shrink - - foreach entry [readdir -nocomplain $dir] { - if {[file isdirectory "$dir/$entry"]} { - scan "$dir/$entry" - } - } -} - -set root [system mediaroot] -file stat "$root/" rootstat -set rootdev $rootstat(dev) - -scan $root +}] 1 diff --git a/var/mongoose/lib/ts.class b/var/mongoose/lib/ts.class index 359c894b..e19df177 100644 --- a/var/mongoose/lib/ts.class +++ b/var/mongoose/lib/ts.class @@ -392,3 +392,28 @@ proc {ts resetnew} {dir} { close $fd } +proc {ts iterate} {callback {verbose 0} {dir ""}} {{rootdev 0}} { + require system.class + if {$dir eq ""} { + set dir [system mediaroot] + file stat "$dir/" rootstat + set rootdev $rootstat(dev) + } + + if {$verbose} { puts "Scanning directory ($dir)" } + + file stat "$dir/" st + if {$st(dev) != $rootdev} return + + foreach entry [readdir -nocomplain $dir] { + if {[file isdirectory "$dir/$entry"]} { + ts iterate $callback $verbose "$dir/$entry" + continue + } + if {![string match {*.ts} $entry]} continue + if {[catch {set ts [ts fetch "$dir/$entry"]}]} continue + if {$ts == 0} continue + $callback $ts + } +} +