Skip to content

Commit

Permalink
storage: Patches metadata changes if there are no modifications to co…
Browse files Browse the repository at this point in the history
…ntent.
  • Loading branch information
rakyll committed Aug 6, 2014
1 parent f54daea commit 8305a80
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions lib/storage/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -261,10 +261,9 @@ Bucket.prototype.createReadStream = function(name) {
* @param {Function} callback Callback function.
*/
Bucket.prototype.write = function(name, opts, callback) {
callback = callback || util.noop;
// TODO(jbd): Support metadata only requests.
var that = this;

callback = callback || util.noop;
var metadata = opts.metadata || {};
var stream = opts.data;
var isStringOrBuffer = typeof stream === 'string' || stream instanceof Buffer;
Expand All @@ -275,6 +274,12 @@ Bucket.prototype.write = function(name, opts, callback) {
stream = new BufferStream(stream);
}

if (!stream) {
// metadata only write
this.makeReq('PATCH', 'o/' + name, null, opts.metadata, callback);
return;
}

var boundary = uuid.v4();
metadata.contentType = metadata.contentType || 'text/plain';
this.conn.createAuthorizedReq({
Expand Down

0 comments on commit 8305a80

Please sign in to comment.