planetiler icon indicating copy to clipboard operation
planetiler copied to clipboard

[FEATURE] Let --download resume downloads rather than start over

Open ZeLonewolf opened this issue 3 years ago • 2 comments

Is your feature request related to a problem? Please describe. When running planetiler with --download, if the run is stopped while a download is in progress, a partial file is left behind. It would save time if a partial file download could optionally be resumed, provided that the partially downloaded file is not too old (i.e. changed on the server).

Describe the solution you'd like A command-line argument, perhaps --resume-download, that instructs planetiler to resume a partial download.

ZeLonewolf avatar May 05 '22 02:05 ZeLonewolf

This should be doable, but definitely not trivial since the downloader could be downloading multiple segments of the file in parallel. The rough approach I'd take is:

  • change the downloader to not delete the temp file we're downloading on exit
  • also store a state file alongside the temp download file that contains some planetiler version number, remote file size (or etag?), the segment start/endpoints, and how many bytes we've downloaded for each segment
  • as we're downloading, periodically flush the current state of the download segments to that state file

Then on resume check for a state file, if it exists and the planetiler version number and remote file size match then resume downloading each chunk where we left off.

if the run is stopped while a download is in progress, a partial file is left behind

Do you actually see the partial file after the JVM exits? It should be deleting that temp file on exit.

msbarry avatar May 06 '22 01:05 msbarry

Yes, I am seeing a partial file left behind on JVM exit: image

This is when pressing the "stop" button in Eclipse, so it's possible that this is doing a non-graceful JVM shutdown.

ZeLonewolf avatar May 07 '22 00:05 ZeLonewolf