Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rewrite download command to be "synchronous". #96

Open
uliwitness opened this issue Feb 17, 2019 · 3 comments
Open

Rewrite download command to be "synchronous". #96

uliwitness opened this issue Feb 17, 2019 · 3 comments
Labels
interpreter Hammer programming language: Parser, tokenizer, interpreter.

Comments

@uliwitness
Copy link
Owner

uliwitness commented Feb 17, 2019

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 a url "foo:///bar/baz" function.

The command's instruction would start the download, call LEOPauseContext(), and from the download completion block call LEOResumeContext(). When it is then called again, it would see that from the kLEOContextResuming flag and instead of starting another download would return the file contents and/or set the result to any error information.

@uliwitness uliwitness added the interpreter Hammer programming language: Parser, tokenizer, interpreter. label Feb 17, 2019
@uliwitness uliwitness assigned uliwitness and unassigned uliwitness Feb 17, 2019
@uliwitness
Copy link
Owner Author

Note: #89 should be done before this, or can likely be done as part of this.

@uliwitness
Copy link
Owner Author

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?

@uliwitness
Copy link
Owner Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
interpreter Hammer programming language: Parser, tokenizer, interpreter.
Projects
None yet
Development

No branches or pull requests

1 participant