Skip to content

Commit 5fcb4f4

Browse files
committed
Uses -NoProfile option when unzipping with PowerShell on Windows to avoid an error caused by the profile.ps1 startup script failing.
Fixes null reference error when unzip native process has stderr data
1 parent 9d9f84b commit 5fcb4f4

File tree

3 files changed

+9
-11
lines changed

3 files changed

+9
-11
lines changed

ant_on_air/src/org/apache/flex/ant/tags/Unzip.as

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ package org.apache.flex.ant.tags
143143
private function winUnzip(source:File):void {
144144
var executable:File = new File("C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe");
145145
var startupInfo:NativeProcessStartupInfo = new NativeProcessStartupInfo();
146-
var arguments:Vector.<String> = new Vector.<String>();
146+
var arguments:Vector.<String> = new <String>["-NoProfile"];
147147

148148
var command:String = "& {";
149149
command += "Param([string]$zipPath,[string]$outPath)"

libraries/ant_on_air.swc

30 Bytes
Binary file not shown.

source/services/AcquireProductService.as

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ package services
4343
import org.robotlegs.starling.mvcs.Actor;
4444

4545
import starling.events.Event;
46+
import flash.utils.IDataInput;
4647

4748
public class AcquireProductService extends Actor implements IAcquireProductService
4849
{
@@ -216,6 +217,7 @@ package services
216217
}
217218
if(this._process)
218219
{
220+
this._process.removeEventListener(NativeProcessExitEvent.EXIT, decompress_completeHandler);
219221
this._process.closeInput();
220222
this._process.exit(true);
221223
this._process = null;
@@ -243,7 +245,7 @@ package services
243245
{
244246
var executable:File = new File("C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe");
245247
var startupInfo:NativeProcessStartupInfo = new NativeProcessStartupInfo();
246-
var arguments:Vector.<String> = new Vector.<String>();
248+
var arguments:Vector.<String> = new <String>["-NoProfile"];
247249

248250
var command:String = "& {";
249251
command += "Param([string]$zipPath,[string]$outPath)"
@@ -265,14 +267,6 @@ package services
265267
command += "\"";
266268
arguments.push("-Command");
267269
arguments.push(command);
268-
/*//with PowerShell 5, the command is much simpler,
269-
//but we need support for older versions of Windows
270-
arguments.push("Expand-Archive");
271-
arguments.push("-Path");
272-
arguments.push(source.nativePath);
273-
arguments.push("-DestinationPath");
274-
arguments.push(this._destinationDirectory.nativePath);
275-
arguments.push("-Force");*/
276270

277271
startupInfo.executable = executable;
278272
startupInfo.arguments = arguments;
@@ -314,7 +308,7 @@ package services
314308

315309
private function decompress_completeHandler(event:NativeProcessExitEvent):void
316310
{
317-
if(!this._destinationDirectory.exists || !this._destinationDirectory.isDirectory)
311+
if(!this._destinationDirectory || !this._destinationDirectory.exists || !this._destinationDirectory.isDirectory)
318312
{
319313
this.cleanup();
320314
this.sdkManagerModel.log(BINARY_DISTRIBUTION_NOT_FOUND_ERROR);
@@ -346,6 +340,10 @@ package services
346340

347341
private function decompress_errorHandler(event:flash.events.Event):void
348342
{
343+
var output:IDataInput = this._process.standardError;
344+
var data:String = output.readUTFBytes(output.bytesAvailable);
345+
this.sdkManagerModel.log(data);
346+
349347
this.cleanup();
350348
this.sdkManagerModel.log(DECOMPRESS_ERROR);
351349
this.dispatchWith(AcquireProductServiceEventType.ERROR, false, DECOMPRESS_ERROR);

0 commit comments

Comments
 (0)