Diff

Differences From Artifact [3ec5e46dc5]:

To Artifact [af80dbf637]:


155
156
157
158
159
160
161


162
163


164
165
166
167
168
169
170
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174







+
+


+
+







		# 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
	}
470
471
472
473
474
475
476
477

478
479
480
481
482
483
484
474
475
476
477
478
479
480

481
482
483
484
485
486
487
488







-
+







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

						if {$file == ".APPFS.WHITEOUT"} {
							continue
						}
580
581
582
583
584
585
586








587
588
589
590
591
592
593
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605







+
+
+
+
+
+
+
+







									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) "/"]
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
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








-
-


-
+

-
-
-
+
+
+
+
+



-

-
-
+
+
+
+
-
+




-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
-

		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 children [getchildren $path]

				set isdirectory 1
				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 isdirectory 1
				set children [getchildren $path]
			}


				if {[llength $children] != 0} {
					return -code error "Asked to delete non-empty directory"
				}
			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]
		}
	}
		set whiteoutfile $pathattrs(whiteoutpath)
		set whiteoutdir [file dirname $whiteoutfile]
		file mkdir $whiteoutdir
		close [open $whiteoutfile w]
	}
}
}