Resuming a download after Safari crashes

Jul 06, '04 09:11:00AM

Contributed by: jammers

A large download is 90% complete when the unexpected happens, and Safari unexpectedly quits. No worries, you say, as Safari has a great feature where it resumes downloads? Well, at least sometimes it does.

I figured out how to get resuming to work after Safari crashes. Here is a little background (for some this will be enough to see what to do, for the rest of us, instructions follow). When you download some file (patch.sit) from a website, a patch.sit.download directory is made in your configured download location. In this directory (accessed via the Terminal or a Control-click and Show Package Contents in the Finder) is patch.sit and another file named Info.plist. It is this info file that is missing the data needed to resume the download.

For example, here is a copy of a download that was interrupted (the first line has been split into three lines for narrower display):

<?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN"
 "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
  <key>DownloadEntryIdentifier</key>
  <string>461E69F1-6900-11D8-A675-000A95984A64</string>
  <key>DownloadEntryPath</key>
  <string>~/downloads/patch.sit.download/patch.sit</string>
  <key>DownloadEntryProgressBytesSoFar</key>
  <integer>16902</integer>
  <key>DownloadEntryProgressTotalToLoad</key>
  <integer>55334659</integer>
  <key>DownloadEntryURL</key>
  <string>http://www.mypatchsite.com/patch.sit</string>
</dict>
</plist>
Here is the same download, but after 'stopping' it using the Download window in Safari:
<?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN"
 "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
  <key>DownloadEntryErrorCodeDictionaryKey</key>
  <integer>-999</integer>
  <key>DownloadEntryErrorDomainDictionaryKey</key>
  <string>NSURLErrorDomain</string>
  <key>DownloadEntryIdentifier</key>
  <string>804C7812-6901-11D8-A806-000A95984A64</string>
  <key>DownloadEntryPath</key>
  <string>~/downloads/patch.sit.download/patch.sit</string>
  <key>DownloadEntryProgressBytesSoFar</key>
  <integer>135350</integer>
  <key>DownloadEntryProgressTotalToLoad</key>
  <integer>55334659</integer>
  <key>DownloadEntryResumeInformation</key>
  <dict>
    <key>NSURLDownloadBytesReceived</key>
    <integer>135350</integer>
    <key>NSURLDownloadEntityTag</key>
    <string>"23a006d-34c5703-b3dce600"</string>
    <key>NSURLDownloadFileModificationDate</key>
    <string>Fri, 13 Feb 2004 22:51:04 GMT</string>
    <key>NSURLDownloadServerModificationDate</key>
    <string>Fri, 13 Feb 2004 22:51:04 GMT</string>
    <key>NSURLDownloadURL</key>
    <string>http://www.mypatchsite.com/patch.sit</string>
  </dict>
  <key>DownloadEntryURL</key>
  <string>http://www.mypatchsite.com/patch.sit</string>
</dict>
</plist>
Notice the extra XML code that's not found in the damaged download. All that is needed to resume the damaged download after crashing is to insert the missing XML. The easiest way to get this is to start downloading the file again, stop it, and then use that download directory to continue your original one:
  1. Start by renaming the original download.
  2. Using the URL from the 'info' file, start downloading the file again.
  3. Stop this download right after it starts using the Download activity window.
  4. Copy your old partially downloaded file (not the whole directory, just the actual download file) into this new download directory. This will overwrite the file that you have just downloaded.
  5. Using the steps mentioned above, view the new download's Info.plist file.
  6. Edit the info file to contain the size of the file that you had managed to download before Safari crashed. This number is the size returned by running ls -l in the Terminal. Note that there are two places you need to edit this -- in the main body of the XML, and in the resume part. The numbers should be the same.
  7. Now go back into Safari, and the Download activity window should still contain that little 'restart' button. Press this and away you go!
[robg adds: I haven't tested this one.]

Comments (5)


Mac OS X Hints
http://hints.macworld.com/article.php?story=20040227044324958