Open uliwitness opened 5 years ago
Note: #89 should be done before this, or can likely be done as part of this.
Open questions: What do we do with headers, progress reporting etc.? Do we keep the download
command for that? Do we save the headers & status codes in a local variable the downloads
that can be accessed after the url
function finishes? Do we call a downloadProgress
handler so another part of the script can at least display progress?
Progress reporting could probably done by calling an optional closure, syntax maybe:
put url "http://example.com" for progress take percentage then put "Downloading:" && percentage
if status of the download is not 200 then
answer "Error downloading: " && the statusMessage of the download
end if
That way we don't duplicate stuff and can get rid of the download
command.
Like the "go" command pauses script execution to wait for a download and then resumes it afterwards, make the
download
command work the same way, and maybe even change it into aurl "foo:///bar/baz"
function.The command's instruction would start the download, call
LEOPauseContext()
, and from the download completion block callLEOResumeContext()
. When it is then called again, it would see that from thekLEOContextResuming
flag and instead of starting another download would return the file contents and/or setthe result
to any error information.