@@ -571,6 +571,9 @@ module.exports = function(AV) {
571571 * @return {AV.Promise } Promise that is resolved when the save finishes.
572572 */
573573 save : function ( ) {
574+ if ( this . id ) {
575+ throw new Error ( 'File already saved. If you want to manipulate a file, use AV.Query to get it.' ) ;
576+ }
574577 var options = null ;
575578 var saveOptions = { } ;
576579 if ( arguments . length === 1 ) {
@@ -637,6 +640,16 @@ module.exports = function(AV) {
637640 return self . _previousSave . _thenRunCallbacks ( options ) ;
638641 } ,
639642
643+ /**
644+ * fetch the file from server. If the server's representation of the
645+ * model differs from its current attributes, they will be overriden,
646+ * @param {Object } fetchOptions Optional options to set 'keys' and
647+ * 'include' option.
648+ * @param {Object } options Optional Backbone-like options object to be
649+ * passed in to set.
650+ * @return {AV.Promise } A promise that is fulfilled when the fetch
651+ * completes.
652+ */
640653 fetch : function ( ) {
641654 var options = null ;
642655 var fetchOptions = { } ;
@@ -650,8 +663,8 @@ module.exports = function(AV) {
650663 var self = this ;
651664 var request = AV . _request ( 'files' , null , this . id , 'GET' ,
652665 fetchOptions ) ;
653- return request . then ( function ( response , status , xhr ) {
654- var value = AV . Object . prototype . parse ( response , status , xhr ) ;
666+ return request . then ( function ( response ) {
667+ var value = AV . Object . prototype . parse ( response ) ;
655668 value . _metaData = value . metaData || { } ;
656669 value . _url = value . url ;
657670 value . _name = value . name ;
0 commit comments