Check-in [5685a8f9a8]
Overview
Comment:Added validity checking for various types
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | tcl-ops
Files: files | file ages | folders
SHA1:5685a8f9a85493348c68a0fc7b9a32d345a74c51
User & Date: rkeene on 2014-11-07 13:04:56
Other Links: manifest | tags
Context
2014-11-07
13:19
Added more reliable write support check-in: d836b9fc43 user: rkeene tags: tcl-ops
13:04
Added validity checking for various types check-in: 5685a8f9a8 user: rkeene tags: tcl-ops
12:26
Added basic write support check-in: db5fcbef28 user: rkeene tags: tcl-ops
Changes

Modified appfsd.tcl from [1c94a0206c] to [25e6dbc0f2].

1
2
3
4
5
6

7
8
9
10
11
12
13
...
394
395
396
397
398
399
400

401
402
403
404
405
406
407
408
...
476
477
478
479
480
481
482
483
484
485







































486
487
488
489
490
491
492
#! /usr/bin/env tclsh

package require http 2.7
package require sqlite3
package require sha1
package require appfsd


namespace eval ::appfs {
	variable cachedir "/tmp/appfs-cache"
	variable ttl 3600
	variable nttl 60

	# User-replacable function to convert a hostname/hash/method to an URL
................................................................................
						if {$pathlen > 3} {
							set retval(version) [lindex $path 3]
							set retval(_children) files
							set retval(_type) versions

							set retval(package_sha1) [::appfs::db onecolumn {SELECT sha1 FROM packages WHERE hostname = $retval(hostname) AND os = $retval(os) AND cpuArch = $retval(cpu) AND version = $retval(version);}]
							if {$retval(package_sha1) == ""} {

								return [list]
							}

							if {$pathlen > 4} {
								set retval(_type) files
								set retval(file) [join [lrange $path 4 end] "/"]
							} else {
								set retval(file) ""
................................................................................
	}

	proc getattr {path} {
		array set pathinfo [_parsepath $path]
		array set retval [list]

		switch -- $pathinfo(_type) {
			"toplevel" - "sites" - "packages" - "os-cpu" - "versions" {
				set retval(type) directory
				set retval(childcount) 2;







































			}
			"files" {
				set retval(packaged) 1

				set localpath [_localpath $pathinfo(package) $pathinfo(hostname) $pathinfo(file)]
				if {[file exists $localpath]} {
					catch {






>







 







>
|







 







|


>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







1
2
3
4
5
6
7
8
9
10
11
12
13
14
...
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
...
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
#! /usr/bin/env tclsh

package require http 2.7
package require sqlite3
package require sha1
package require appfsd
package require platform

namespace eval ::appfs {
	variable cachedir "/tmp/appfs-cache"
	variable ttl 3600
	variable nttl 60

	# User-replacable function to convert a hostname/hash/method to an URL
................................................................................
						if {$pathlen > 3} {
							set retval(version) [lindex $path 3]
							set retval(_children) files
							set retval(_type) versions

							set retval(package_sha1) [::appfs::db onecolumn {SELECT sha1 FROM packages WHERE hostname = $retval(hostname) AND os = $retval(os) AND cpuArch = $retval(cpu) AND version = $retval(version);}]
							if {$retval(package_sha1) == ""} {
								set retval(_children) dead
								return [array get retval]
							}

							if {$pathlen > 4} {
								set retval(_type) files
								set retval(file) [join [lrange $path 4 end] "/"]
							} else {
								set retval(file) ""
................................................................................
	}

	proc getattr {path} {
		array set pathinfo [_parsepath $path]
		array set retval [list]

		switch -- $pathinfo(_type) {
			"toplevel" {
				set retval(type) directory
				set retval(childcount) 2;
			}
			"sites" {
				set check [::appfs::db onecolumn {SELECT 1 FROM packages WHERE hostname = $pathinfo(hostname);}]
				if {$check == "1"} {
					set retval(type) directory
					set retval(childcount) 2;
				}
			}
			"packages" {
				set check [::appfs::db onecolumn {SELECT 1 FROM packages WHERE hostname = $pathinfo(hostname) AND package = $pathinfo(package);}]
				if {$check == "1"} {
					set retval(type) directory
					set retval(childcount) 2;
				}
			}
			"os-cpu" {
				if {$pathinfo(os) == "platform" && $pathinfo(cpu) == ""} {
					set retval(type) symlink
					set retval(source) [platform::generic]
				} else {
					set check [::appfs::db onecolumn {
						SELECT 1 FROM packages WHERE hostname = $pathinfo(hostname) AND package = $pathinfo(package) AND os = $pathinfo(os) AND cpuArch = $pathinfo(cpu);
					}]
					if {$check == "1"} {
						set retval(type) directory
						set retval(childcount) 2;
					}
				}
			}
			"versions" {
				if {$pathinfo(version) == "latest"} {
					set retval(type) symlink
					set retval(source) "1.0"
				} else {
					if {[info exists pathinfo(package_sha1)] && $pathinfo(package_sha1) != ""} {
						set retval(type) directory
						set retval(childcount) 2;
					}
				}
			}
			"files" {
				set retval(packaged) 1

				set localpath [_localpath $pathinfo(package) $pathinfo(hostname) $pathinfo(file)]
				if {[file exists $localpath]} {
					catch {