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
13
14
15
16
17
18

19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37









38
39
40
41
42
43
44
45
		}
		append retval "[string range $hash [expr {$idx * 2}] end]"

		return $retval
	}

	proc _cachefile {url key {keyIsHash 1}} {

		if {$keyIsHash} {
			set key [_hash_sep $key]
		}

		set file [file join $::appfs::cachedir $key]

		file mkdir [file dirname $file]

		if {![file exists $file]} {
			set tmpfile "${file}.new"

			set fd [open $tmpfile "w"]
			fconfigure $fd -translation binary

			set token [::http::geturl $url -channel $fd -binary true]
			set ncode [::http::ncode $token]
			::http::reset $token
			close $fd










			if {$ncode == "200"} {
				file rename -force -- $tmpfile $file
			} else {
				file delete -force -- $tmpfile
			}
		}

		return $file







>

|


|














>
>
>
>
>
>
>
>
>
|







12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
		}
		append retval "[string range $hash [expr {$idx * 2}] end]"

		return $retval
	}

	proc _cachefile {url key {keyIsHash 1}} {
		set filekey $key
		if {$keyIsHash} {
			set filekey [_hash_sep $filekey]
		}

		set file [file join $::appfs::cachedir $filekey]

		file mkdir [file dirname $file]

		if {![file exists $file]} {
			set tmpfile "${file}.new"

			set fd [open $tmpfile "w"]
			fconfigure $fd -translation binary

			set token [::http::geturl $url -channel $fd -binary true]
			set ncode [::http::ncode $token]
			::http::reset $token
			close $fd

			if {$keyIsHash} {
				catch {
					set hash [string tolower [exec openssl sha1 $tmpfile]]
					regsub {.*= *} $hash {} hash
				}
			} else {
				set hash $key
			}

			if {$ncode == "200" && $hash == $key} {
				file rename -force -- $tmpfile $file
			} else {
				file delete -force -- $tmpfile
			}
		}

		return $file