Skip to content

Commit

Permalink
adding a drop method
Browse files Browse the repository at this point in the history
  • Loading branch information
chelm committed Feb 3, 2015
1 parent 70c7e6e commit f42a57b
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 1 deletion.
11 changes: 11 additions & 0 deletions controller/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,17 @@ var Controller = function( Github, BaseController ){
controller.index = function(req, res){
res.render(__dirname + '/../views/index');
};

// drops the cache for an item
controller.drop = function(req, res){
Github.drop(req.params.user, req.params.repo, req.params.file, req.query, function(error, itemJson){
if (error) {
res.status(400).send( error );
} else {
res.json( itemJson );
}
});
};

controller.thumbnail = function(req, res){
// check the image first and return if exists
Expand Down
17 changes: 17 additions & 0 deletions models/Github.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,23 @@ var Github = function( koop ){
});
};*/


// drops the item from the cache
github.drop = function( user, repo, file, options, callback ){
var key = [user, repo, file].join('/');
var type = 'Github';
var dir = [ type.toLowerCase(), user, repo, file].join(':');
koop.Cache.remove(type, key, options, function(err, res){
koop.files.removeDir( 'files/' + dir, function(err, res){
koop.files.removeDir( 'tiles/'+ dir, function(err, res){
koop.files.removeDir( 'thumbs/'+ dir, function(err, res){
callback(err, true);
});
});
});
});
};

return github;

};
Expand Down
3 changes: 2 additions & 1 deletion routes/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@ module.exports = {
'get /github/:user/:repo/:file/FeatureServer/:layer/:method': 'featureservice',
'get /github/:user/:repo/:file/thumbnail' : 'thumbnail',
'get /github/:user/:repo/:file/tiles/:z/:x/:y.:format': 'tiles',
'get /github/:user/:repo/:file/:layer/tiles/:z/:x/:y.:format': 'tiles'
'get /github/:user/:repo/:file/:layer/tiles/:z/:x/:y.:format': 'tiles',
'get /github/:user/:repo/:file/drop': 'drop'
}

0 comments on commit f42a57b

Please sign in to comment.