webif/var/mongoose/lib/bin/strip-update
hummypkg 070fd7a749 update
git-svn-id: file:///root/webif/svn/humax/pkg/src/webif/trunk@1436 2a923420-c742-0410-a762-8d5b09965624
2013-03-05 00:10:38 +00:00

60 lines
1.0 KiB
Plaintext
Executable File

#!/mod/bin/jimsh
source /mod/webif/lib/setup
require system.class ts.class
proc do_shrink {ts} {
if {[$ts flag "Shrunk"]} { return }
set file [file rootname [$ts get file]]
if {[$ts inuse]} { return }
if {[catch {
set perc [exec /mod/bin/stripts -aq $file]
} msg]} {
return
}
if {[string match {*%} $perc]} {
set perc [string range $perc 0 end-1]
} else {
set perc 0
}
if {$perc == 0} {
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