Saturday, September 22, 2007 [Tweets] [Favorites]

Resuming ADC Downloads

Downloading from Apple’s developer seeding site takes a long time with a DSL connection, and when using current versions of Safari and Firefox an interrupted download means that you have to start over. It’s virtually impossible for my download to go uninterrupted long enough to get a whole DVD-sized file. Fortunately, Mac OS X includes a built-in command-line tool called curl that can automatically retry and resume downloads. Normally you can invoke it using curl -O 'URL' to download URL into the current directory. It’s slightly more complicated if you want handle cookie-authorization and URL redirection:

  1. Log in using your browser and copy the file’s URL.
  2. Use curl 'URL' -D FILE to dump the headers into FILE.
  3. Open the file and note the cookie (set-cookie: NAME=VALUE) and new URL (location: NEWURL).
  4. Now download the file using curl -O 'NEWURL' -b 'NAME=VALUE' --retry 100 -C -. This will retry and auto-resume up to 100 times.
  5. You can also add --limit-rate 100K to limit the amount of bandwidth that curl uses if you want to reserve some of your connection for other use.

7 Comments

I was able to resume the Leopard seed download using the resume button in Safari's Downloads not only past the 15 minute login session but across machine sleep and a few hours after I accidently put the machine to sleep.

Jesper: Are you using Safari 3? It works for me with Safari 3, but I don't have that installed. It's never worked for me with Safari 2 (after the first 15 minutes). The other advantage to using curl is that it will resume immediately, without your having to be there to click a button.

Safari 3: Yes.

`curl`: Across sleeping?

You should be able to just use
`curl -O URL --location --cookie-jar $(mktemp -t curl) --retry 100 -C -`.
`--location` takes care of handling the redirection, `--cookie-jar` will take care of storing the cookie (in a new file called /tmp/curl.XXXXXXXX if you the same mktemp call).

Jesper: I'd expect it to work across sleeping if you use --speed-limit.

Martin: That's much better--thanks! However, unfortunately -O uses the original, not redirected, filename.

Martin: I take that back. When I do it your way, it throws away what it's downloaded before retrying.

Thank you very much indeed! This is just what I was looking for. ADC keeps throwing me off at the mo, presumably because everyone is downloading the gm of Leopard.

Stay up-to-date by subscribing to the Comments RSS Feed for this post.

Leave a Comment