[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; ievt.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
RE: [flexcoders] FZip loads cached zip before downloading online
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:[EMAIL PROTECTED] On Behalf Of diigiibot Sent: Friday, October 17, 2008 3:31 AM To: flexcoders@yahoogroups.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; ievt.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
Re: [flexcoders] FZip loads cached zip before downloading online
On Oct 17, 2008, at 10:17 AM, Kevin Benz wrote: 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? Compare file sizes. cheers, jon
Re: [flexcoders] FZip loads cached zip before downloading online
On Oct 17, 2008, at 10:17 AM, Kevin Benz wrote: 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? Scratch my last comment btw... duh... when you're not connected you have no idea if it's been completed. What you can do is see if FZip will open up the ZIP archive that didn't download completely. You should have an error thrown that it's not valid because, well, the ZIP archive wouldn't be valid if it's not fully downloaded. just a thought, jb