Skip to content

Commit

Permalink
Fixed method 'getFile' of Container object, to reflect changes in cor…
Browse files Browse the repository at this point in the history
…e.js
  • Loading branch information
indutny committed Dec 1, 2010
1 parent 74607d1 commit 4af8b4a
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
14 changes: 11 additions & 3 deletions lib/cloudfiles/container.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -31,9 +31,17 @@ Container.prototype = {
this.client.destoryContainer(this.name, callback); this.client.destoryContainer(this.name, callback);
}, },


getFiles: function (callback) { getFiles: function (download, callback) {
var self = this; var self = this;
this.client.getFiles(this.name, function (err, files) {
// download can be omitted: (...).getFiles(callback);
// In this case first argument will be a function
if (typeof download === 'function' && !(download instanceof RegExp)) {
callback = download;
download = false;
}

this.client.getFiles(this.name, download, function (err, files) {
self.files = files; self.files = files;
callback(null, files); callback(null, files);
}); });
Expand Down Expand Up @@ -61,4 +69,4 @@ Container.prototype = {
this.count = details.count || 0; this.count = details.count || 0;
this.bytes = details.bytes || 0; this.bytes = details.bytes || 0;
} }
}; };
3 changes: 2 additions & 1 deletion lib/cloudfiles/core.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ Cloudfiles.prototype.getFiles = function (container, download, callback) {
file.container = container; file.container = container;
return new (cloudfiles.StorageObject)(self, file); return new (cloudfiles.StorageObject)(self, file);
}); });

callback(null, results); callback(null, results);
return; return;
} }
Expand Down Expand Up @@ -288,4 +289,4 @@ Cloudfiles.prototype.cdnUrl = function () {
json = (typeof(args[args.length - 1]) === 'boolean') && args.pop(); json = (typeof(args[args.length - 1]) === 'boolean') && args.pop();


return [this.config.cdnUrl].concat(args).join('/') + (json ? '?format=json' : ''); return [this.config.cdnUrl].concat(args).join('/') + (json ? '?format=json' : '');
}; };
2 changes: 1 addition & 1 deletion test/data/test-config.json
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
"username": "test-username", "username": "test-username",
"apiKey": "test-apiKey" "apiKey": "test-apiKey"
} }
} }

0 comments on commit 4af8b4a

Please sign in to comment.