; replying myself with updated versions .... downloaded safely more than 
100 MB today, correctly appends to interrupted downloads, etc.

REBOL [
     Title: "download-it!"
    Author: "Petr Krenzelok"
     Email: [EMAIL PROTECTED]
      File: %download-it!.r
   Version: 1.0
   Comment: {Tries to download file, till complete. Still place for 
improvements:
              - GUI - not necessary imo
              - log events to file?
              - download list of files?
              - callbacks? E.g. notification by sending email, sms, etc.
              - whatever ... as for me though - it works, so - finished 
... :-)
            }
]

source-file: to-url ask "Paste URL: "
target-file: first request-file/title "Save (append) to ..." "Select"
source-size: size? source-file

either exists? target-file [target-size: size? target-file][target-size: 0]

if target-size == source-size [print "Nothing to download, file already 
complete ..." halt]
if target-size > 0 [print ["Appending at " target-size "bytes"]]

start: now/time
forever [

   while [error? try [source: open/binary/direct/no-wait/skip 
source-file target-size]][
    print "Can't open source file .... waiting 10 min"
    wait 00:10
   ]

   while [
     wait source
     all [
       not error? try [data: copy/part source 8192]
       data
     ]
   ][
     write/binary/append target-file data
     target-size: target-size + length? data 
     print ["Source-size: " source-size tab "Downloaded: " target-size 
tab "Time: " now/time - start]
   ]

  if target-size >= source-size [print "Download complete ..." break]

  print "Download interrupted ..."
  print ["Continuing at " target-size "bytes"]
  close source
]

close source

-- 
To unsubscribe from this list, please send an email to
[EMAIL PROTECTED] with "unsubscribe" in the 
subject, without the quotes.

Reply via email to