Skip to content

Commit

Permalink
Modified the 'moveTo' method of the virtual and physical resources to…
Browse files Browse the repository at this point in the history
… be more reliable
  • Loading branch information
AdrienCastex committed May 31, 2017
1 parent 0a41414 commit 44b38fe
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 6 deletions.
5 changes: 3 additions & 2 deletions lib/resource/physical/PhysicalResource.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,17 @@ var PhysicalResource = (function (_super) {
return;
}
var oldName = this.name;
this.name = newName;
this.removeFromParent(function (e) {
if (e) {
_this.name = oldName;
callback(e);
}
else
else {
_this.name = newName;
parent.addChild(_this, function (e) {
callback(e);
});
}
});
};
PhysicalResource.prototype.rename = function (newName, callback) {
Expand Down
5 changes: 3 additions & 2 deletions lib/resource/virtual/VirtualResource.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,17 @@ var VirtualResource = (function (_super) {
return;
}
var oldName = this.name;
this.name = newName;
this.removeFromParent(function (e) {
if (e) {
_this.name = oldName;
callback(e);
}
else
else {
_this.name = newName;
parent.addChild(_this, function (e) {
callback(e);
});
}
});
};
VirtualResource.prototype.rename = function (newName, callback) {
Expand Down
4 changes: 3 additions & 1 deletion src/resource/physical/PhysicalResource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,19 @@ export abstract class PhysicalResource extends StandardResource
}

const oldName = this.name;
this.name = newName;
this.removeFromParent((e) => {
if(e)
{
this.name = oldName;
callback(e);
}
else
{
this.name = newName;
parent.addChild(this, (e) => {
callback(e);
})
}
})
}
rename(newName : string, callback : Return2Callback<string, string>)
Expand Down
4 changes: 3 additions & 1 deletion src/resource/virtual/VirtualResource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,19 @@ export abstract class VirtualResource extends StandardResource
}

const oldName = this.name;
this.name = newName;
this.removeFromParent((e) => {
if(e)
{
this.name = oldName;
callback(e);
}
else
{
this.name = newName;
parent.addChild(this, (e) => {
callback(e);
})
}
})
}
rename(newName : string, callback : Return2Callback<string, string>)
Expand Down

0 comments on commit 44b38fe

Please sign in to comment.