a glob of nerdishness

May 9, 2009

How I resume incomplete ADC downloads

written by natevw @ 9:38 pm

If you follow the Apple news/rumor sites, you’ll have heard that Apple has been (pre-)releasing software like crazy lately. I can neither confirm nor deny these rumors. Between my marginal ISP and the dank, dusty cellars underneath Apple’s public website, I get plenty of half-finished large downloads regardless of what Apple is up to.

When Safari thinks it’s finished downloading an incomplete file, I like to use curl to finish. My usual trick isn’t enough for the Apple Developer Connection’s password-protected files, and it took me a while to figure those out. Eventually, with the help of two helpful posts and some trial-and-error, this is the method I’ve settled on:

  1. Copy partially downloaded file if it’s fairly large (because sometimes I mess up)
  2. Log into ADC in a browser, and copy the download link
  3. curl -c $(mktemp -t curl) -L -o '<Partially Downloaded File>' -C - '<Download URL>'

It is very important to quote the Download URL, because it may contain special shell characters! This is the main reason I copy the partial download; I don’t want to blow away a large partial download with a bit of error page HTML.

This works as follows: -c $(mktemp -t curl) tells curl to keep track of cookies in a temporary file, and -L means to follow redirects. The downloaded output file is specified via -o and -C - means to continue at the offset where this output file stops. I don’t include an option to automatically retry on failure, because if the session expires this could lead to a loss of the newly appended data if the download is replaced by an error page.

1 Comment

  1. Thanks for posting this! I just spent an hour hopelessly trying to figure out a way to do this and you just saved me. Thanks a ton!

    Comment by jono — July 24, 2009 @ 5:23 pm

RSS feed for comments on this post.

Sorry, the comment form is closed at this time.