Skip to content

Commit

Permalink
Add a warning to the storage/file#move method.
Browse files Browse the repository at this point in the history
We should make it clear that this is a composition of two methods,
and if the second (storage/file#delete) were to fail,
a lingering file would be left around (which could cost money).

Fixes #544
  • Loading branch information
jgeewax authored and stephenplusplus committed May 8, 2015
1 parent 6bc5b9d commit 6c650e1
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions lib/storage/file.js
Original file line number Diff line number Diff line change
Expand Up @@ -235,10 +235,18 @@ File.prototype.copy = function(destination, callback) {
};

/**
* Move this file to another location. By default, this will move
* the file to the same bucket, but you can choose to move it
* Move this file to another location. By default, this will move
* the file to the same bucket, but you can choose to move it
* to another Bucket by providing either a Bucket or File object.
*
* **Warning**:
* There is currently no atomic `move` method in the Google Cloud Storage API,
* so this method is a composition of {module:storage/file#copy} (to the new
* location) and {module:storage/file#delete} (from the old location). While
* unlikely, it is possible that an error returned to your callback could be
* triggered from either one of these API calls failing, which could leave a
* duplicate file lingering.
*
* @throws {Error} If the destination file is not provided.
*
* @param {string|module:storage/bucket|module:storage/file} destination -
Expand All @@ -265,7 +273,7 @@ File.prototype.copy = function(destination, callback) {
* // but contains instead:
* // - "my-image-new.png"
*
* // `destinationFile` is an instance of a File object that refers
* // `destinationFile` is an instance of a File object that refers
* // to your new file.
* });
*
Expand All @@ -281,7 +289,7 @@ File.prototype.copy = function(destination, callback) {
* // `another-bucket` now contains:
* // - "my-image.png"
*
* // `destinationFile` is an instance of a File object that refers
* // `destinationFile` is an instance of a File object that refers
* // to your new file.
* });
*
Expand Down

0 comments on commit 6c650e1

Please sign in to comment.