When you destroy the FZip object, don't necessarily know and if you
don't know, you have to clean up after yourself. Remember, when you use
HTTP, you are subject to timeouts that may or may not expire as you
expect them let alone the myriad of other errors along the way
(permissions, server error, etc). If you only wait for a Complete event,
then the HTTP object is left hanging and the file is certainly in a
dirty state as well. 

 

K

 

From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of diigiibot
Sent: Friday, October 17, 2008 9:09 AM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Re: FZip loads cached zip before downloading
online

 

Yes, that could be a solution. I'll try it out. 
Only I'm not sure the partially downloaded zip will be removed from
the temp folder when I remove the FZip object.

--- In flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com>
, "Kevin Benz" <[EMAIL PROTECTED]> wrote:
>
> Not sure exactly what is happening but I suggest an improvement to
your
> approach.
> 
> 
> 
> You should detect the change in network connection status and use that
> event to flush any objects that are waiting on an event to fire. AIR
> fires a NETWORK_CHANGED event and I would make sure you clean up your
> objects at that point. You cannot depend on the quality of the bits
you
> just downloaded regardless and need to re-enter the process.
> 
> 
> 
> KFB 
> 
> 
> 
> From: flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com>
[mailto:flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com>
] On
> Behalf Of diigiibot
> Sent: Friday, October 17, 2008 3:31 AM
> To: flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com> 
> Subject: [flexcoders] FZip loads cached zip before downloading online
> 
> 
> 
> I'm using FZip in an AIR application, the application loads the zip
> from a location on our server, unpacks the zip and move the files to
> their local folder. Everything runs smooth until I cut off my internet
> connection while the zip is downloading.
> When I restart the application it looks like FZip is first checking
> the temp folder for the cached zip and if found, it uses that one to
> unzip, even if the zip was not completed the last time.
> 
> Does anyone know of a way to prevent that?
> 
> I use the default load method of the FZip library, this is a part of
> the code I use.
> 
> var moduleLink:String = [EMAIL PROTECTED];
> 
> var zip:FZip = new FZip();
> 
> zip.addEventListener(Event.COMPLETE, onComplete);
> 
> zip.load(new URLRequest(moduleLink));
> 
> private function onComplete(evt:Event):void 
> {
> var moduleDir:File =
> File.applicationStorageDirectory.resolvePath("modules");
> 
> var outStream:FileStream;
> 
> for(var i:int; i<evt.target.getFileCount();i++)
> {
> var zipFile:FZipFile = evt.target.getFileAt(i);
> 
> if(zipFile.sizeUncompressed == 0 &&
> zipFile.filename.toString().substr(-1) == "/")
> {
> var rootDir:File =
>
File.applicationStorageDirectory.resolvePath("modules/"+zipFile.filename
> .toString());
> }
> else
> {
> var tempFile:File = moduleDir.resolvePath(zipFile.filename);
> 
> outStream = new FileStream();
> 
> outStream.open(tempFile, FileMode.WRITE);
> 
> outStream.writeBytes(zipFile.content, 0, zipFile.sizeUncompressed);
> 
> outStream.close();
> }
> }
> evt.target.close();
> }
> 
> Thanks in advance
>

 

<<image001.jpg>>

<<image002.jpg>>

Reply via email to