Check-in [99c9d35a89]
Overview
Comment:Added executable bit
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:99c9d35a89e44a419adc9d05813c9f21fc3cc8b5
User & Date: rkeene on 2014-09-09 06:10:49
Other Links: manifest | tags
Context
2014-09-09
06:46
Updated to download files as binary check-in: d0513156ec user: rkeene tags: trunk
06:10
Added executable bit check-in: 99c9d35a89 user: rkeene tags: trunk
06:01
Updated with basic functionality check-in: f66a795908 user: rkeene tags: trunk
Changes

Modified README.md from [1bb6f9042d] to [399b33ad33].

    16     16       /opt/appfs/hostname/package/os-cpuArch/version
    17     17       /opt/appfs/hostname/sha1/
    18     18       	Fetches: http://hostname/appfs/sha1/<sha1>
    19     19       	Contains CSV file:
    20     20       		type,time,extraData,name
    21     21       		type == directory; extraData = (null)
    22     22       		type == symlink; extraData = source
    23         -    		type == file; extraData = size,sha1
           23  +    		type == file; extraData = size,perms,sha1
    24     24   
    25     25       /opt/appfs/hostname/{sha1,package/os-cpuArch/version}/file
    26     26       	Fetches: http://hostname/appfs/sha1/<sha1>
    27     27   
    28     28   Database
    29     29   --------
    30     30       packages(hostname, sha1, package, version, os, cpuArch, isLatest, haveManifest)
    31         -    files(package_sha1, type, time, source, size, file_sha1, file_name, file_directory)
           31  +    files(package_sha1, type, time, source, size, perms, file_sha1, file_name, file_directory)

Modified appfs-mk from [de5f8534e5] to [1fd261ccc1].

    54     54   				extra_data=''
    55     55   				;;
    56     56   			symlink)
    57     57   				stat_format='%Y'
    58     58   				extra_data="$(readlink "${filename}")"
    59     59   				;;
    60     60   			file)
           61  +				if [ -x "${filename}" ]; then
           62  +					extra_data='x'
           63  +				else
           64  +					extra_data=''
           65  +				fi
           66  +
    61     67   				stat_format='%Y,%s'
    62     68   				filename_hash="$(sha1 "${filename}")"
    63         -				extra_data="${filename_hash}"
           69  +				extra_data="${extra_data},${filename_hash}"
    64     70   
    65     71   				filename_intree="${appfsdir}/sha1/${filename_hash}"
    66     72   
    67     73   				if [ ! -e "${filename_intree}" ]; then
    68     74   					cat "${filename}" > "${filename_intree}.tmp"
    69     75   
    70     76   					mv "${filename_intree}.tmp" "${filename_intree}"

Modified appfs.c from [fb14cea935] to [62dbc078fa].

   453    453   	}
   454    454   
   455    455   	return(retval);
   456    456   }
   457    457   
   458    458   static int appfs_getfileinfo_cb(void *_pathinfo, int columns, char **values, char **names) {
   459    459   	struct appfs_pathinfo *pathinfo = _pathinfo;
   460         -	const char *type, *time, *source, *size;
          460  +	const char *type, *time, *source, *size, *perms, *sha1;
   461    461   
   462    462   	type = values[0];
   463    463   	time = values[1];
   464    464   	source = values[2];
   465    465   	size = values[3];
          466  +	perms = values[4];
          467  +	sha1 = values[5];
   466    468   
   467    469   	pathinfo->time = strtoull(time, NULL, 10);
   468    470   
   469    471   	if (strcmp(type, "file") == 0) {
   470    472   		pathinfo->type = APPFS_PATHTYPE_FILE;
   471         -		pathinfo->typeinfo.file.executable = 0;
          473  +
          474  +		if (!size) {
          475  +			size = "0";
          476  +		}
          477  +
          478  +		if (!perms) {
          479  +			perms = "";
          480  +		}
          481  +
   472    482   		pathinfo->typeinfo.file.size = strtoull(size, NULL, 10);
          483  +
          484  +		if (strcmp(perms, "x") == 0) {
          485  +			pathinfo->typeinfo.file.executable = 1;
          486  +		} else {
          487  +			pathinfo->typeinfo.file.executable = 0;
          488  +		}
   473    489   
   474    490   		return(0);
   475    491   	}
   476    492   
   477    493   	if (strcmp(type, "directory") == 0) {
   478    494   		pathinfo->type = APPFS_PATHTYPE_DIRECTORY;
   479    495   		pathinfo->typeinfo.dir.childcount = 0;
................................................................................
   513    529   		file = path;
   514    530   		directory = "";
   515    531   	} else {
   516    532   		*file = '\0';
   517    533   		file++;
   518    534   	}
   519    535   
   520         -	sql = sqlite3_mprintf("SELECT type, time, source, size FROM files WHERE package_sha1 = %Q AND file_directory = %Q AND file_name = %Q;", package_hash, directory, file);
          536  +	sql = sqlite3_mprintf("SELECT type, time, source, size, perms, file_sha1 FROM files WHERE package_sha1 = %Q AND file_directory = %Q AND file_name = %Q;", package_hash, directory, file);
   521    537   	if (sql == NULL) {
   522    538   		APPFS_DEBUG("Call to sqlite3_mprintf failed.");
   523    539   
   524    540   		free(path);
   525    541   
   526    542   		return(-EIO);
   527    543   	}

Modified appfs.tcl from [604641f8e6] to [10ad08f811].

    58     58   		if {![info exists ::appfs::db]} {
    59     59   			file mkdir $::appfs::cachedir
    60     60   
    61     61   			sqlite3 ::appfs::db [file join $::appfs::cachedir cache.db]
    62     62   		}
    63     63   
    64     64   		_db eval {CREATE TABLE IF NOT EXISTS packages(hostname, sha1, package, version, os, cpuArch, isLatest, haveManifest);}
    65         -		_db eval {CREATE TABLE IF NOT EXISTS files(package_sha1, type, time, source, size, file_sha1, file_name, file_directory);}
           65  +		_db eval {CREATE TABLE IF NOT EXISTS files(package_sha1, type, time, source, size, perms, file_sha1, file_name, file_directory);}
    66     66   	}
    67     67   
    68     68   	proc download {hostname hash {method sha1}} {
    69     69   		set url "http://$hostname/appfs/$method/$hash"
    70     70   		set file [_cachefile $url $hash]
    71     71   
    72     72   		if {![file exists $file]} {
................................................................................
   180    180   			set fileInfo(directory) [join [lrange $fileInfo(name) 0 end-1] "/"]
   181    181   			set fileInfo(name) [lindex $fileInfo(name) end]
   182    182   
   183    183   			set work [lrange $work 2 end-1]
   184    184   			switch -- $fileInfo(type) {
   185    185   				"file" {
   186    186   					set fileInfo(size) [lindex $work 0]
   187         -					set fileInfo(sha1) [lindex $work 1]
          187  +					set fileInfo(perms) [lindex $work 1]
          188  +					set fileInfo(sha1) [lindex $work 2]
   188    189   				}
   189    190   				"symlink" {
   190    191   					set fileInfo(source) [lindex $work 0]
   191    192   				}
   192    193   			}
   193    194   
   194         -			_db eval {INSERT INTO files (package_sha1, type, time, source, size, file_sha1, file_name, file_directory) VALUES ($package_sha1, $fileInfo(type), $fileInfo(time), $fileInfo(source), $fileInfo(size), $fileInfo(sha1), $fileInfo(name), $fileInfo(directory) );}
          195  +			_db eval {INSERT INTO files (package_sha1, type, time, source, size, perms, file_sha1, file_name, file_directory) VALUES ($package_sha1, $fileInfo(type), $fileInfo(time), $fileInfo(source), $fileInfo(size), $fileInfo(perms), $fileInfo(sha1), $fileInfo(name), $fileInfo(directory) );}
   195    196   			_db eval {UPDATE packages SET haveManifest = 1 WHERE sha1 = $package_sha1;}
   196    197   		}
   197    198   
   198    199   		return COMPLETE
   199    200   	}
   200    201   }