diff options
author | Marius <mariausol@gmail.com> | 2011-01-31 00:24:50 +0200 |
---|---|---|
committer | Marius <mariausol@gmail.com> | 2011-01-31 00:24:50 +0200 |
commit | eec811ebfad073304adf6ac267f22111d383895a (patch) | |
tree | 7ddee7a5dcd7035053ac62e11ccc9231d897bf50 /tex/context/base/data-sch.lua | |
parent | 91675d8e11906bc15351278f8865d41de6bcc06d (diff) | |
download | context-eec811ebfad073304adf6ac267f22111d383895a.tar.gz |
beta 2011.01.23 21:48
Diffstat (limited to 'tex/context/base/data-sch.lua')
-rw-r--r-- | tex/context/base/data-sch.lua | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/tex/context/base/data-sch.lua b/tex/context/base/data-sch.lua index cac4baab7..af86cd726 100644 --- a/tex/context/base/data-sch.lua +++ b/tex/context/base/data-sch.lua @@ -23,6 +23,34 @@ schemes.threshold = 24 * 60 * 60 directives.register("schemes.threshold", function(v) schemes.threshold = tonumber(v) or schemes.threshold end) +local cleaners = { } + +schemes.cleaners = cleaners + +function cleaners.none(specification) + return specification.original +end + +function cleaners.strip(specification) + return (gsub(specification.original,"[^%a%d%.]+","-")) +end + +function cleaners.md5(specification) + return file.addsuffix(md5.hex(specification.original),file.suffix(specification.path)) +end + +local cleaner = cleaners.strip + +directives.register("schemes.cleanmethod", function(v) cleaner = cleaners[v] or cleaners.strip end) + +function resolvers.schemes.cleanname(specification) + local hash = cleaner(specification) + if trace_schemes then + report_schemes("hashing %s to %s",specification.original,hash) + end + return hash +end + local cached, loaded, reused, thresholds, handlers = { }, { }, { }, { }, { } local function runcurl(name,cachename) -- will use sockets instead or the curl library @@ -33,7 +61,7 @@ end local function fetch(specification) local original = specification.original local scheme = specification.scheme - local cleanname = gsub(original,"[^%a%d%.]+","-") + local cleanname = schemes.cleanname(specification) local cachename = caches.setfirstwritablefile(cleanname,"schemes") if not cached[original] then statistics.starttiming(schemes) |