diff --git a/src/applications/drydock/blueprint/DrydockAmazonEC2HostBlueprintImplementation.php b/src/applications/drydock/blueprint/DrydockAmazonEC2HostBlueprintImplementation.php --- a/src/applications/drydock/blueprint/DrydockAmazonEC2HostBlueprintImplementation.php +++ b/src/applications/drydock/blueprint/DrydockAmazonEC2HostBlueprintImplementation.php @@ -861,9 +861,17 @@ 'Releasing lease %d', $lease->getID())); - $cmd = $lease->getInterface('command'); $path = $lease->getAttribute('path'); + // Set the path back to null for the lease. This ensures on Windows + // machines we don't change to the directory we're about to delete, because + // Windows implicitly locks a directory from deletion whenever there is a + // process with it's current working directory within that directory or + // any of it's sub-directories. + $lease->setAttribute('path', null); + + $cmd = $lease->getInterface('command'); + try { $this->log(pht( 'Removing contents of \'%s\' on host', @@ -883,7 +891,12 @@ 'occur when files are locked by the operating system. The exception '. 'message was \'%s\'.', $ex->getMessage())); + return; } + + $this->log(pht( + 'Removed contents of \'%s\' on host successfully', + $path)); } public function getType() {