Skip to content

Commit

Permalink
add unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
stephenplusplus committed Mar 10, 2015
1 parent 5616626 commit c0ce479
Show file tree
Hide file tree
Showing 2 changed files with 334 additions and 8 deletions.
12 changes: 6 additions & 6 deletions lib/storage/bucket.js
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,7 @@ Bucket.prototype.makePublic = function(options, callback) {
return;
}

if (options.files) {
if (options.includeFiles) {
options.public = true;
self.makeAllFilesPublicPrivate_(options, callback);
return;
Expand Down Expand Up @@ -766,16 +766,16 @@ Bucket.prototype.makeAllFilesPublicPrivate_ = function(options, callback) {

var MAX_PARALLEL_LIMIT = 10;
var errors = [];
var filesProcessed = [];
var updatedFiles = [];

// Start processing files, iteratively fetching more as necessary.
processFiles({}, function (err) {
if (err || errors.length > 0) {
callback(err || errors, filesProcessed);
callback(err || errors, updatedFiles);
return;
}

callback(null, filesProcessed);
callback(null, updatedFiles);
});

function processFiles(query, callback) {
Expand All @@ -785,7 +785,7 @@ Bucket.prototype.makeAllFilesPublicPrivate_ = function(options, callback) {
return;
}

// Iterate through each file and make it public/private.
// Iterate through each file and make it public or private.
async.eachLimit(files, MAX_PARALLEL_LIMIT, processFile, function(err) {
if (err) {
callback(err);
Expand Down Expand Up @@ -821,7 +821,7 @@ Bucket.prototype.makeAllFilesPublicPrivate_ = function(options, callback) {
return;
}

filesProcessed.push(file);
updatedFiles.push(file);
callback();
}
}
Expand Down
Loading

0 comments on commit c0ce479

Please sign in to comment.