urlProgress during the download of a .zip archive solved

Getting into LiveCode for iOS? Ask your questions here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2729
Joined: Sat Dec 22, 2007 5:35 pm
Contact:

urlProgress during the download of a .zip archive solved

Post by jmburnod » Sat Oct 27, 2012 7:17 pm

Hi All,
I use urlProgress during the download of a .zip archive like this

Code: Select all

on urlProgress tPathZipS, pStatus
   if the environment = "mobile" then
      put pStatus && the ticks into fld "fCommentInstall"
      if pStatus is "downloaded" then
         wait 1000 milliseconds
         listZipContents
      end if
   end if
end urlProgress

It seem "lisZipContent" is sent before the download of the zip is finished
I have this error message

zipperr.Not a zip archiverevzipOpenarchive
revZipEnumerateItems
zipperr.Not a zip archiverevzipOpenarchive

What i'm wrong ?
I use LC 5.02 xCode 4.2.1

Thank in advance for your help

Best

Jean-Marc
Last edited by jmburnod on Tue Nov 20, 2012 9:24 am, edited 1 time in total.
https://alternatic.ch

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2729
Joined: Sat Dec 22, 2007 5:35 pm
Contact:

Re: urlProgress during the download of a .zip archive

Post by jmburnod » Sun Oct 28, 2012 7:44 pm

Hi All,
I forgot to specify in my first post that the listZipContent message work well if i send it from a btn. I must wait "a moment".
I also tried

Code: Select all

send "listZipContent" to me in 1000 milliseconds
With the same result:
zipperr.Not a zip archiverevzipOpenarchive
revZipEnumerateItems
zipperr.Not a zip archiverevzipOpenarchiv
Do someone have a way to solving this mistake ?

Thanks

Jean-Marc
https://alternatic.ch

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: urlProgress during the download of a .zip archive

Post by Simon » Mon Oct 29, 2012 4:18 pm

Hi Jean-Marc,
Since noone else has replied I'll give it a shot.
One thing to make sure of is that your zip file is compressed using "normal". They have different levels with names like "maximum" and "ultra". I think only "normal" is supported.

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Re: urlProgress during the download of a .zip archive

Post by Mark » Mon Oct 29, 2012 5:07 pm

Hi Jean-Marc,

There's a good chance that your problem is solved if you write

Code: Select all

wait 1000 milliseconds with mesages
and probably you don't need to wait a full second. 200 millisecs should be enough.

Kind regards,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2729
Joined: Sat Dec 22, 2007 5:35 pm
Contact:

Re: urlProgress during the download of a .zip archive

Post by jmburnod » Tue Oct 30, 2012 2:09 am

hi mark,

Tanks a lot.I just return from abroad. I'll test it tomorrow.

Kind regards

Jean-Marc
https://alternatic.ch

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2729
Joined: Sat Dec 22, 2007 5:35 pm
Contact:

Re: urlProgress during the download of a .zip archive

Post by jmburnod » Tue Oct 30, 2012 11:04 am

Hi Mark
One big progress with your help
I always have the same error but it don't stop the script like before. I'll do a simplified stack to catch the lizard's head
Kind regards
Jean-Marc
https://alternatic.ch

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Re: urlProgress during the download of a .zip archive

Post by Mark » Tue Oct 30, 2012 11:07 am

Hi Jean-Marc,

What's the error and how was the script stopped before?

Mark
Last edited by Mark on Thu Nov 08, 2012 12:03 am, edited 1 time in total.
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2729
Joined: Sat Dec 22, 2007 5:35 pm
Contact:

Re: urlProgress during the download of a .zip archive

Post by jmburnod » Tue Oct 30, 2012 7:53 pm

Hi Mark

It repeat this error message two times, then it bypass the next and work fine for revZipEnumerateItems and revZipExtractItemToFile with a custom progressbar.

zipper.Can't open file.No Such file or directoryrevZipOpenArchive
revZipEnumerateItems
zipperr.Not a zip archiverevzipOpenarchive

The mistake
An "answer dialog" which I use to signify to the user that the installation is ended makes mistake
If it is removed it, the script works fine like that:

1. listZipContents
2. revZipExtractItemToFile with a custom progressbar
3. delete file (myArchive.zip)
All files are copied where it is expected and the zip file is deleted

Kind regards

Jean-Marc
https://alternatic.ch

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2729
Joined: Sat Dec 22, 2007 5:35 pm
Contact:

Re: urlProgress during the download of a .zip archive

Post by jmburnod » Thu Nov 15, 2012 8:39 pm

Hi All,
I read in the doc:

Code: Select all

on urlProgress pUrl, pStatus
   if pStatus is "downloaded" then
      answer "Finished downloading" with "Okay"
   end if
end urlProgress
But a "Downloaded" message is sent before the end of the download.
In this case it is necessary to ignore the first "downloaded" message.

The stack in attachment download a zip archive (50 images, 1.4 Mo) in the document folder and delete it after an answer dialog.
You can see the result in the field "fSpy"

Best regards
Jean-marc
Attachments
DownloadZip502IOS.livecode.zip
(4.68 KiB) Downloaded 329 times
https://alternatic.ch

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Re: urlProgress during the download of a .zip archive

Post by Mark » Mon Nov 19, 2012 12:57 am

Hi Jean-Marc,

I tested this and tried to find a solution that doesn't involve a hack. I can't find a reasonable solution and believe this problem should be reported as a bug.

Apparently, you could use the load URL command with a callback message. Perhaps this would be a good alternative.

Kind regards,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7390
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: urlProgress during the download of a .zip archive

Post by jacque » Mon Nov 19, 2012 5:47 am

The first "downloaded" message is from your "testConnect" handler. The second one is from the file download. If there is a urlProgress handler, it will capture all download activity. If you comment out the testConnect handler, you will only see one "downloaded" message.

Remove the sNumdownloaded counter and watch the log field. You will see the server is contacted, a short download occurs (the test url connection) and completes ("downoaded" is logged,) and then the server is contacted a second time for the longer file download.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2729
Joined: Sat Dec 22, 2007 5:35 pm
Contact:

Re: urlProgress during the download of a .zip archive

Post by jmburnod » Mon Nov 19, 2012 10:21 am

Hi Jacque and Mark,
Thanks
Fortunately, there is not a bug. Jacque is right, my "testconnect" handler send a "downloaded" message.
Kind regards
Jean-Marc
https://alternatic.ch

Post Reply