#! /usr/bin/env tclkit # special version of new submit to fix archives built before the # header was detected, and before the info.* files were written source [file join [file dirname [info script]] util.tcl] proc submitpart {type path data} { set md [md5c $data] set ams [amspath $md [string length $data] 1] if {![file exists $ams]} { puts " $ams $type [file tail $path] ([string length $data]b)" set cdata [vfs::zip -mode compress $data] if {[string length $cdata] < [string length $data]} { set data $cdata } set fd [open $ams w] fconfigure $fd -translation binary puts -nonewline $fd $data close $fd } return $md } proc submitsk {path go} { puts $path: if {![file readable $path]} { puts "\tnot readable, skipped" return } if {[file isdir $path]} { puts "\tdirectory, skipped" return } set e [catch { mkheader $path } start] if {$e} { puts "\t$start" } set head "" set fd [open $path] fconfigure $fd -translation binary set tail [read $fd] close $fd set hmd5 [submitpart h $path $head] set tmd5 [submitpart t $path $tail] set hlen [string length $head] set hams [file tail [amspath $hmd5 $hlen]] set tlen [string length $tail] set tams [file tail [amspath $tmd5 $tlen]] set p [string range [file tail $path] 0 end-12] set t [file mtime $path] regexp -- {-(\d+)-(\d+)$} $path - a b set sig [expr {(($a-10000)<<16)|($b-10000)}] if {$go} { set x [mk::row append idb.logs name $p vid $sig date $t \ hmd $hmd5 hsz [string length $head] \ tmd $tmd5 tsz [string length $tail]] set x [lindex [split $x !] end] puts $::ifd [list $x $p $sig $t $hams $hlen $tams $tlen] } else { puts [list $p $sig $t $hams $hlen $tams $tlen] } } set go 1 switch -- [lindex $argv 0] { "" { puts "Usage: submit ?-n? starkit ..." exit } -n { set go 0 set argv [lrange $argv 1 end] } } if {$go} { set ifd [open info.txt a] mk::file open idb info.mk if {[catch mk::view layout idb.logs]} { # only set if not defined, to avoid losing columns added later mk::view layout idb.logs {name vid:I date:I hmd:B hsz:I tmd:B tsz:I} } } foreach sk $argv { if {[catch { submitsk $sk $go } err]} { puts $errorInfo } } if {$go} { mk::file close idb close $ifd }