Check-in [7321b530dd]
Overview
Comment:Updated to check SHA1 of downloaded artifacts
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:7321b530dd7ebabe11c5066c576d44a23b7b7544
User & Date: rkeene on 2014-09-10 07:38:40
Other Links: manifest | tags
Context
2014-09-10
07:42
Renamed index generator to "mkfs" check-in: 475a868eae user: rkeene tags: trunk
07:38
Updated to check SHA1 of downloaded artifacts check-in: 7321b530dd user: rkeene tags: trunk
07:33
Removed extraneous reference to stringify check-in: ce18c8a9b9 user: rkeene tags: trunk
Changes

Modified appfsd.tcl from [8e33ab2552] to [ad6530f32d].

    12     12   		}
    13     13   		append retval "[string range $hash [expr {$idx * 2}] end]"
    14     14   
    15     15   		return $retval
    16     16   	}
    17     17   
    18     18   	proc _cachefile {url key {keyIsHash 1}} {
           19  +		set filekey $key
    19     20   		if {$keyIsHash} {
    20         -			set key [_hash_sep $key]
           21  +			set filekey [_hash_sep $filekey]
    21     22   		}
    22     23   
    23         -		set file [file join $::appfs::cachedir $key]
           24  +		set file [file join $::appfs::cachedir $filekey]
    24     25   
    25     26   		file mkdir [file dirname $file]
    26     27   
    27     28   		if {![file exists $file]} {
    28     29   			set tmpfile "${file}.new"
    29     30   
    30     31   			set fd [open $tmpfile "w"]
................................................................................
    31     32   			fconfigure $fd -translation binary
    32     33   
    33     34   			set token [::http::geturl $url -channel $fd -binary true]
    34     35   			set ncode [::http::ncode $token]
    35     36   			::http::reset $token
    36     37   			close $fd
    37     38   
    38         -			if {$ncode == "200"} {
           39  +			if {$keyIsHash} {
           40  +				catch {
           41  +					set hash [string tolower [exec openssl sha1 $tmpfile]]
           42  +					regsub {.*= *} $hash {} hash
           43  +				}
           44  +			} else {
           45  +				set hash $key
           46  +			}
           47  +
           48  +			if {$ncode == "200" && $hash == $key} {
    39     49   				file rename -force -- $tmpfile $file
    40     50   			} else {
    41     51   				file delete -force -- $tmpfile
    42     52   			}
    43     53   		}
    44     54   
    45     55   		return $file