Download queue with libURL

Sarah Reichelt sarah.reichelt at gmail.com
Wed Jun 2 20:00:08 EDT 2010


On Mon, May 31, 2010 at 9:28 PM, Terry Vogelaar <tvogelaar at de-mare.nl> wrote:
> I can't figure out what is wrong with this script:
>
> on wachtrij
>   global kjoejoe
>   if line 1 of kjoejoe <> "" then
>      put line 1 of kjoejoe && the number of lines of kjoejoe
>      set the itemdel to tab
>      switch item 1 of line 1 of kjoejoe
>         case "up"
>            libURLftpUploadFile item 2 of line 1 of kjoejoe, item 3 of line 1
> of kjoejoe, "wachtrij"
>            break
>         case "down"
>            libURLDownloadToFile item 2 of line 1 of kjoejoe, item 3 of line
> 1 of kjoejoe, "wachtrij"
>      end switch
>      delete line 1 of kjoejoe
>   end if
> end wachtrij


I think the problem is that when you issue a call to
libURLftpUploadFile or libURLDownloadToFile with a callback, the
processing doesn't stop & wait. So I think all the uploads & downloads
are trying to start at the same time, so the later ones are failing.

I usually have 2 routines called something like startTransfer and
transferComplete.

startTransfer takes the first line in the queue and starts processing
it, with transferComplete as the callback.
transferComplete checks the result and it is all worked OK, it deletes
the first line of the queue and then calls startTransfer again if the
queue is not empty.

Also check out libURLSetStatusCallback and libURLSetLogField which are
both really useful for debugging and keeping people informed as to the
progress or the file transfers.

HTH,
Sarah



More information about the use-livecode mailing list