Diff

Differences From Artifact [3ec5e46dc5]:

To Artifact [af80dbf637]:


155
156
157
158
159
160
161


162
163


164
165
166
167
168
169
170
...
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
...
580
581
582
583
584
585
586








587
588
589
590
591
592
593
...
720
721
722
723
724
725
726
727
728
729
730


731

732
733
734
735

736
737
738
739
740
741


742
743

744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
		# Create indexes
		db eval {CREATE INDEX IF NOT EXISTS sites_index ON sites (hostname);}
		db eval {CREATE INDEX IF NOT EXISTS packages_index ON packages (hostname, package, version, os, cpuArch);}
		db eval {CREATE INDEX IF NOT EXISTS files_index ON files (package_sha1, file_name, file_directory);}
	}

	proc download {hostname hash {method sha1}} {


		set url [_construct_url $hostname $hash $method]
		set file [_cachefile $url $hash]



		if {![file exists $file]} {
			return -code error "Unable to fetch (file does not exist: $file)"
		}

		return $file
	}
................................................................................
						set remove [string range $file 0 end-15]
						set idx [lsearch -exact $retval $remove]
						if {$idx != -1} {
							set retval [lreplace $retval $idx $idx]
						}
					}

					foreach file [glob -nocomplain -tails -directory $dir -types {d f l} {{.,}*}] {
						if {$file == "." || $file == ".."} {
							continue
						}

						if {$file == ".APPFS.WHITEOUT"} {
							continue
						}
................................................................................
									set retval(perms) ""
								}
							}
							"link" {
								set retval(type) "symlink"
								set retval(source) [file readlink $localpath]
							}








						}
					} err
				} else {
					if {![file exists $whiteoutpath]} {
						set retval(is_remotefile) 1

						set work [split $pathinfo(file) "/"]
................................................................................

		if {![info exists pathattrs(packaged)]} {
			return -code error "invalid type"
		}

		set localpath $pathattrs(localpath)

		set whiteout 0
		set isdirectory 0
		if {[info exists pathattrs(is_localfile)]} {
			if {[file isdirectory $localpath]} {


				set whiteout 1


				set isdirectory 1
				set children [getchildren $path]
			}

			file delete -force -- $localpath
		} elseif {[info exists pathattrs(is_remotefile)]} {
			if {$pathattrs(type) == "directory"} {
				set isdirectory 1
				set children [getchildren $path]
			}



			set whiteout 1

		} else {
			return -code error "Unknown if file is remote or local !?"
		}

		if {$isdirectory} {
			if {$children != [list]} {
				return -code error "Asked to delete non-empty directory"
			}
		}

		if {$whiteout} {
			set whiteoutfile $pathattrs(whiteoutpath)
			set whiteoutdir [file dirname $whiteoutfile]
			file mkdir $whiteoutdir
			close [open $whiteoutfile w]
		}
	}
}







>
>


>
>







 







|







 







>
>
>
>
>
>
>
>







 







<
<


>
>
|
>
|
<
<

>



<

|
>
>
|
<
>




<
<
<
<
<
<
<
|
|
|
|
|
|
<
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
...
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
...
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
...
732
733
734
735
736
737
738


739
740
741
742
743
744
745


746
747
748
749
750

751
752
753
754
755

756
757
758
759
760







761
762
763
764
765
766

		# Create indexes
		db eval {CREATE INDEX IF NOT EXISTS sites_index ON sites (hostname);}
		db eval {CREATE INDEX IF NOT EXISTS packages_index ON packages (hostname, package, version, os, cpuArch);}
		db eval {CREATE INDEX IF NOT EXISTS files_index ON files (package_sha1, file_name, file_directory);}
	}

	proc download {hostname hash {method sha1}} {
		::appfsd::simulate_user_fs_leave

		set url [_construct_url $hostname $hash $method]
		set file [_cachefile $url $hash]

		::appfsd::simulate_user_fs_enter

		if {![file exists $file]} {
			return -code error "Unable to fetch (file does not exist: $file)"
		}

		return $file
	}
................................................................................
						set remove [string range $file 0 end-15]
						set idx [lsearch -exact $retval $remove]
						if {$idx != -1} {
							set retval [lreplace $retval $idx $idx]
						}
					}

					foreach file [glob -nocomplain -tails -directory $dir -types {d f l p s} {{.,}*}] {
						if {$file == "." || $file == ".."} {
							continue
						}

						if {$file == ".APPFS.WHITEOUT"} {
							continue
						}
................................................................................
									set retval(perms) ""
								}
							}
							"link" {
								set retval(type) "symlink"
								set retval(source) [file readlink $localpath]
							}
							"fifo" {
								# Capitalized so that the first char is unique
								set retval(type) "Fifo"
							}
							"socket" {
								# Capitalized so that the first char is unique
								set retval(type) "Socket"
							}
						}
					} err
				} else {
					if {![file exists $whiteoutpath]} {
						set retval(is_remotefile) 1

						set work [split $pathinfo(file) "/"]
................................................................................

		if {![info exists pathattrs(packaged)]} {
			return -code error "invalid type"
		}

		set localpath $pathattrs(localpath)



		if {[info exists pathattrs(is_localfile)]} {
			if {[file isdirectory $localpath]} {
				set children [getchildren $path]

				if {[llength $children] != 0} {
					return -code error "Asked to delete non-empty directory"
				}


			}

			file delete -force -- $localpath
		} elseif {[info exists pathattrs(is_remotefile)]} {
			if {$pathattrs(type) == "directory"} {

				set children [getchildren $path]

				if {[llength $children] != 0} {
					return -code error "Asked to delete non-empty directory"
				}

			}
		} else {
			return -code error "Unknown if file is remote or local !?"
		}








		set whiteoutfile $pathattrs(whiteoutpath)
		set whiteoutdir [file dirname $whiteoutfile]
		file mkdir $whiteoutdir
		close [open $whiteoutfile w]
	}
}