return l
end
+local function assertFlags(flags)
+ flags = flags or {}
+ local known = {
+ cachable = "boolean",
+ cache = "boolean",
+ check_only = "boolean",
+ islocal = "boolean",
+ push_permissions = "string",
+ try_hardlink = "boolean",
+ writeback = "boolean",
+ }
+
+ assertIsTable(flags)
+ for key in pairs(flags) do
+ if known[key] == "string" then
+ assertIsString(flags[key])
+ elseif known[key] == "boolean" then
+ assertIsBoolean(flags[key])
+ else
+ error(err.new("unknown field: flags.%s value: %q type: %s",
+ key, tostring(flags[key]), type(flags[key])))
+ end
+ end
+end
+
--- create a new cache entry
-- @param c a cache table
-- @param server the remote server name
ce.server = server
ce.remote_url = ru.url
+ assertFlags(flags)
+
ce.flags = {}
ce.flags.cachable = flags.cachable
ce.flags.cache = flags.cache and flags.cachable
if not flags then
flags = {}
end
+ assertFlags(flags)
-- fetch the file
if ce.flags.cache and flags.cache ~= false then
-- cache is enabled:
end
end
- -- removed unused flags.chmod feature, keep an assert just to make sure
- assertIsNil(flags.chmod)
-
return true
end
if not ce then
return false, e:cat(re)
end
+ assertFlags(flags)
if ce.flags.cache and flags.cache ~= false then
-- cache is enabled:
-- push the file from source to cache and from cache to
assert(type(c) == "table", "invalid cache")
assert(type(server) == "string" and server ~= "", "invalid server")
assert(type(flags) == "table", "invalid flags")
+ assertFlags(flags)
local ce, re
function cache.writeback(c, server, location, flags)
local e = err.new("writeback failed")
local rc, re
+ assertFlags(flags)
local ce, re = cache.ce_by_server(c, server)
if not ce then
if not ce then
return false, e:cat(re)
end
+ assertFlags(flags)
if not ce.flags.cache then
return true
end
if not ce then
return false, e:cat(re)
end
+ assertFlags(flags)
if ce.flags.cache then
-- cache enabled. cache the file and return path to cached
-- file