Index: README.md ================================================================== --- README.md +++ README.md @@ -18,14 +18,14 @@ Fetches: http://hostname/appfs/sha1/ Contains CSV file: type,time,extraData,name type == directory; extraData = (null) type == symlink; extraData = source - type == file; extraData = size,sha1 + type == file; extraData = size,perms,sha1 /opt/appfs/hostname/{sha1,package/os-cpuArch/version}/file Fetches: http://hostname/appfs/sha1/ Database -------- packages(hostname, sha1, package, version, os, cpuArch, isLatest, haveManifest) - files(package_sha1, type, time, source, size, file_sha1, file_name, file_directory) + files(package_sha1, type, time, source, size, perms, file_sha1, file_name, file_directory) Index: appfs-mk ================================================================== --- appfs-mk +++ appfs-mk @@ -56,13 +56,19 @@ symlink) stat_format='%Y' extra_data="$(readlink "${filename}")" ;; file) + if [ -x "${filename}" ]; then + extra_data='x' + else + extra_data='' + fi + stat_format='%Y,%s' filename_hash="$(sha1 "${filename}")" - extra_data="${filename_hash}" + extra_data="${extra_data},${filename_hash}" filename_intree="${appfsdir}/sha1/${filename_hash}" if [ ! -e "${filename_intree}" ]; then cat "${filename}" > "${filename_intree}.tmp" Index: appfs.c ================================================================== --- appfs.c +++ appfs.c @@ -455,23 +455,39 @@ return(retval); } static int appfs_getfileinfo_cb(void *_pathinfo, int columns, char **values, char **names) { struct appfs_pathinfo *pathinfo = _pathinfo; - const char *type, *time, *source, *size; + const char *type, *time, *source, *size, *perms, *sha1; type = values[0]; time = values[1]; source = values[2]; size = values[3]; + perms = values[4]; + sha1 = values[5]; pathinfo->time = strtoull(time, NULL, 10); if (strcmp(type, "file") == 0) { pathinfo->type = APPFS_PATHTYPE_FILE; - pathinfo->typeinfo.file.executable = 0; + + if (!size) { + size = "0"; + } + + if (!perms) { + perms = ""; + } + pathinfo->typeinfo.file.size = strtoull(size, NULL, 10); + + if (strcmp(perms, "x") == 0) { + pathinfo->typeinfo.file.executable = 1; + } else { + pathinfo->typeinfo.file.executable = 0; + } return(0); } if (strcmp(type, "directory") == 0) { @@ -515,11 +531,11 @@ } else { *file = '\0'; file++; } - 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); + 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); if (sql == NULL) { APPFS_DEBUG("Call to sqlite3_mprintf failed."); free(path); Index: appfs.tcl ================================================================== --- appfs.tcl +++ appfs.tcl @@ -60,11 +60,11 @@ sqlite3 ::appfs::db [file join $::appfs::cachedir cache.db] } _db eval {CREATE TABLE IF NOT EXISTS packages(hostname, sha1, package, version, os, cpuArch, isLatest, haveManifest);} - _db eval {CREATE TABLE IF NOT EXISTS files(package_sha1, type, time, source, size, file_sha1, file_name, file_directory);} + _db eval {CREATE TABLE IF NOT EXISTS files(package_sha1, type, time, source, size, perms, file_sha1, file_name, file_directory);} } proc download {hostname hash {method sha1}} { set url "http://$hostname/appfs/$method/$hash" set file [_cachefile $url $hash] @@ -182,19 +182,20 @@ set work [lrange $work 2 end-1] switch -- $fileInfo(type) { "file" { set fileInfo(size) [lindex $work 0] - set fileInfo(sha1) [lindex $work 1] + set fileInfo(perms) [lindex $work 1] + set fileInfo(sha1) [lindex $work 2] } "symlink" { set fileInfo(source) [lindex $work 0] } } - _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) );} + _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) );} _db eval {UPDATE packages SET haveManifest = 1 WHERE sha1 = $package_sha1;} } return COMPLETE } }