#!/mod/bin/jimsh

source /mod/webif/lib/setup
require system.class ts.class

ts iterate [lambda {ts} {
	#puts "    [$ts get file]"
	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
	}
}] 1

