Commit a1199b0e authored by Alex Beregszaszi's avatar Alex Beregszaszi

Store imports as read-only files

parent ddf06bd2
......@@ -493,15 +493,10 @@ var run = function () {
})
}
// FIXME: at some point we should invalidate the cache
var cachedRemoteFiles = {}
function handleImportCall (url, cb) {
var githubMatch
if (files.exists(url)) {
cb(null, files.get(url))
} else if (url in cachedRemoteFiles) {
cb(null, cachedRemoteFiles[url])
} else if ((githubMatch = /^(https?:\/\/)?(www.)?github.com\/([^/]*\/[^/]*)\/(.*)/.exec(url))) {
handleGithubCall(githubMatch[3], githubMatch[4], function (err, content) {
if (err) {
......@@ -509,7 +504,8 @@ var run = function () {
return
}
cachedRemoteFiles[url] = content
// FIXME: at some point we should invalidate the cache
files.addReadOnly(url, content)
cb(null, content)
})
} else if (/^[^:]*:\/\//.exec(url)) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment