Skip to content
This repository has been archived by the owner on Sep 1, 2021. It is now read-only.

Commit

Permalink
fixing bug with tags not getting updated properly
Browse files Browse the repository at this point in the history
  • Loading branch information
ekristen committed Jun 10, 2014
1 parent 6e4c183 commit 902a478
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
4 changes: 1 addition & 3 deletions index/middleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,7 @@ module.exports = function(config, redis, logger) {
req.repo = repo;

// Check for repo permissions
req.permission = value.permissions[repo] || 'none';
// Check for namespace permissions
req.permission = value.permissions[req.params.namespace] || 'none';
req.permission = value.permissions[req.namespace] || value.permissions[req.repo] || 'none';

if (req.permission == "none") {
logger.debug({req: req, permission: req.permission, statusCode: 403, message: 'access denied: permission not set'});
Expand Down
16 changes: 14 additions & 2 deletions index/repos.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ module.exports = function(redis, logger) {
}

var images = {};
var tags = {};

if (value == null)
var value = []
Expand All @@ -43,17 +44,28 @@ module.exports = function(redis, logger) {

// check if tag is set
if (typeof(i['Tag']) !== "undefined") {
i_data['Tag'] = i['Tag'];
tags[i['Tag']] = iid;
//i_data['Tag'] = i['Tag'];
}

images[iid] = i_data;
}

var final_tags = {};
for (var key in tags) {
final_tags[tags[key]] = key;
}

var final_images = [];
for (var key in images) {
// Set the tag on the Image.
if (typeof(final_tags[key]) !== "undefined") {
images[key]['Tag'] = final_tags[key];
}

final_images.push(images[key]);
}

redis.set('images:' + req.params.namespace + '_' + req.params.repo, JSON.stringify(final_images), function(err, status) {
if (err) {
logger.error({err: err, type: 'redis', namespace: req.params.namespace, repo: req.params.repo});
Expand Down

0 comments on commit 902a478

Please sign in to comment.