diff --git a/lib/resource/physical/PhysicalResource.js b/lib/resource/physical/PhysicalResource.js index 394999f2..744661e4 100644 --- a/lib/resource/physical/PhysicalResource.js +++ b/lib/resource/physical/PhysicalResource.js @@ -29,8 +29,7 @@ var PhysicalResource = (function (_super) { return _this; } PhysicalResource.prototype.moveTo = function (parent, newName, overwrite, callback) { - var _this = this; - StandardResource_1.StandardResource.standardMoveTo(this, parent, newName, overwrite, function (name) { return _this.name = name; }, callback); + StandardResource_1.StandardResource.standardMoveTo(this, parent, newName, overwrite, callback); }; PhysicalResource.prototype.rename = function (newName, callback) { var _this = this; diff --git a/lib/resource/std/StandardResource.d.ts b/lib/resource/std/StandardResource.d.ts index 660e7fbe..8da1b56b 100644 --- a/lib/resource/std/StandardResource.d.ts +++ b/lib/resource/std/StandardResource.d.ts @@ -41,6 +41,6 @@ export declare abstract class StandardResource implements IResource { protected updateLastModified(): void; protected removeFromParent(callback: SimpleCallback): void; static standardRemoveFromParent(resource: IResource, callback: SimpleCallback): void; - static standardMoveTo(resource: IResource, parent: IResource, newName: string, overwrite: boolean, setName: (name: string) => void, callback: SimpleCallback): void; + static standardMoveTo(resource: IResource, parent: IResource, newName: string, overwrite: boolean, callback: SimpleCallback): void; static standardMimeType(resource: IResource, targetSource: boolean, callback: ReturnCallback): void; } diff --git a/lib/resource/std/StandardResource.js b/lib/resource/std/StandardResource.js index 3ba8cc6e..36bdb6b7 100644 --- a/lib/resource/std/StandardResource.js +++ b/lib/resource/std/StandardResource.js @@ -99,7 +99,7 @@ var StandardResource = (function () { else callback(null); }; - StandardResource.standardMoveTo = function (resource, parent, newName, overwrite, setName, callback) { + StandardResource.standardMoveTo = function (resource, parent, newName, overwrite, callback) { parent.getChildren(function (e, children) { new Workflow_1.Workflow() .each(children, function (child, cb) { return child.webName(function (e, name) { @@ -130,9 +130,13 @@ var StandardResource = (function () { callback(e); } else { - setName(newName); - parent.addChild(resource, function (e) { - callback(e); + resource.rename(newName, function (e, oldName, newName) { + if (e) + callback(e); + else + parent.addChild(resource, function (e) { + callback(e); + }); }); } }); diff --git a/lib/resource/virtual/VirtualResource.js b/lib/resource/virtual/VirtualResource.js index 48fbd3c8..7b576561 100644 --- a/lib/resource/virtual/VirtualResource.js +++ b/lib/resource/virtual/VirtualResource.js @@ -32,8 +32,7 @@ var VirtualResource = (function (_super) { this.removeFromParent(callback); }; VirtualResource.prototype.moveTo = function (parent, newName, overwrite, callback) { - var _this = this; - StandardResource_1.StandardResource.standardMoveTo(this, parent, newName, overwrite, function (name) { return _this.name = name; }, callback); + StandardResource_1.StandardResource.standardMoveTo(this, parent, newName, overwrite, callback); }; VirtualResource.prototype.rename = function (newName, callback) { var oldName = this.name; diff --git a/src/resource/physical/PhysicalResource.ts b/src/resource/physical/PhysicalResource.ts index c6e4a02c..b9af1904 100644 --- a/src/resource/physical/PhysicalResource.ts +++ b/src/resource/physical/PhysicalResource.ts @@ -30,7 +30,7 @@ export abstract class PhysicalResource extends StandardResource abstract delete(callback : SimpleCallback) moveTo(parent : IResource, newName : string, overwrite : boolean, callback : SimpleCallback) { - StandardResource.standardMoveTo(this, parent, newName, overwrite, (name) => this.name = name, callback); + StandardResource.standardMoveTo(this, parent, newName, overwrite, callback); } rename(newName : string, callback : Return2Callback) { diff --git a/src/resource/std/StandardResource.ts b/src/resource/std/StandardResource.ts index 56b8d9de..4c8dcdb8 100644 --- a/src/resource/std/StandardResource.ts +++ b/src/resource/std/StandardResource.ts @@ -159,7 +159,7 @@ export abstract class StandardResource implements IResource else callback(null); } - public static standardMoveTo(resource : IResource, parent : IResource, newName : string, overwrite : boolean, setName : (name : string) => void, callback : SimpleCallback) + public static standardMoveTo(resource : IResource, parent : IResource, newName : string, overwrite : boolean, callback : SimpleCallback) { parent.getChildren((e, children) => { new Workflow() @@ -196,9 +196,13 @@ export abstract class StandardResource implements IResource } else { - setName(newName); - parent.addChild(resource, (e) => { - callback(e); + resource.rename(newName, (e, oldName, newName) => { + if(e) + callback(e); + else + parent.addChild(resource, (e) => { + callback(e); + }) }) } }) diff --git a/src/resource/virtual/VirtualResource.ts b/src/resource/virtual/VirtualResource.ts index 7e1160e2..48e5bc89 100644 --- a/src/resource/virtual/VirtualResource.ts +++ b/src/resource/virtual/VirtualResource.ts @@ -32,7 +32,7 @@ export abstract class VirtualResource extends StandardResource } moveTo(parent : IResource, newName : string, overwrite : boolean, callback : SimpleCallback) { - StandardResource.standardMoveTo(this, parent, newName, overwrite, (name) => this.name = name, callback); + StandardResource.standardMoveTo(this, parent, newName, overwrite, callback); } rename(newName : string, callback : Return2Callback) {