@@ -23,7 +23,6 @@ package services
23
23
24
24
import flash.desktop.NativeProcess ;
25
25
import flash.desktop.NativeProcessStartupInfo ;
26
- import flash.events.ErrorEvent ;
27
26
import flash.events.Event ;
28
27
import flash.events.IOErrorEvent ;
29
28
import flash.events.NativeProcessExitEvent ;
@@ -38,18 +37,19 @@ package services
38
37
import flash.system.Capabilities ;
39
38
import flash.utils.ByteArray ;
40
39
41
- import model.SDKManagerModel ;
42
40
import model.ProductConfigurationItem ;
41
+ import model.SDKManagerModel ;
43
42
44
43
import org.as3commons.zip.Zip ;
44
+ import org.as3commons.zip.ZipErrorEvent ;
45
45
import org.as3commons.zip.ZipEvent ;
46
46
import org.as3commons.zip.ZipFile ;
47
47
import org.robotlegs.starling.mvcs.Actor ;
48
48
49
49
import starling.events.Event ;
50
50
51
51
public class AcquireProductService extends Actor implements IAcquireProductService
52
- {
52
+ {
53
53
private static const ACQUISITION_IN_PROGRESS_ERROR : String = "Downloading the Feathers SDK failed. A download is already in progress." ;
54
54
private static const NO_PRODUCT_SELECTED_ERROR : String = "Downloading the Feathers SDK failed. No version of the Feathers SDK is selected." ;
55
55
private static const NOT_FOUND_ON_SERVER_ERROR : String = "Downloading the Feathers SDK failed. The binary distribution was not found on the server." ;
@@ -222,7 +222,7 @@ package services
222
222
this . _zip . close ();
223
223
this . _zip . removeEventListener (ZipEvent. FILE_LOADED , onFileLoaded);
224
224
this . _zip . removeEventListener (flash. events . Event . COMPLETE , decompress_completeHandler);
225
- this . _zip . removeEventListener (ErrorEvent . ERROR , decompress_errorHandler);
225
+ this . _zip . removeEventListener (ZipErrorEvent . PARSE_ERROR , decompress_errorHandler);
226
226
this . _zip = null ;
227
227
}
228
228
if (this . _process )
@@ -262,8 +262,20 @@ package services
262
262
263
263
this . _zip . addEventListener (ZipEvent. FILE_LOADED , onFileLoaded, false , 0 , true );
264
264
this . _zip . addEventListener (flash. events . Event . COMPLETE , decompress_completeHandler, false , 0 , true );
265
- this . _zip . addEventListener (ErrorEvent . ERROR , decompress_errorHandler, false , 0 , true );
266
- this . _zip . loadBytes (zipFileBytes);
265
+ this . _zip . addEventListener (ZipErrorEvent. PARSE_ERROR , decompress_errorHandler, false , 0 , true );
266
+ try
267
+ {
268
+ //I discovered that an error can be thrown during loadBytes()
269
+ //where ZipErrorEvent.PARSE_ERROR is not dispatched
270
+ this . _zip . loadBytes (zipFileBytes);
271
+ }
272
+ catch (error : Error )
273
+ {
274
+ this . cleanup();
275
+ this . sdkManagerModel. log (DECOMPRESS_ERROR );
276
+ this . dispatchWith(AcquireProductServiceEventType. ERROR , false , DECOMPRESS_ERROR );
277
+ return ;
278
+ }
267
279
}
268
280
269
281
private function onFileLoaded (e :ZipEvent ):void
@@ -366,6 +378,8 @@ package services
366
378
this . dispatchWith(AcquireProductServiceEventType. COMPLETE );
367
379
}
368
380
381
+ //this listener is used for both unzip and untar, so the event types are
382
+ //different, but they both extend from flash.events.Event
369
383
private function decompress_errorHandler (event :flash .events.Event):void
370
384
{
371
385
this . cleanup();
0 commit comments