On Sun, Apr 27, 2014 at 7:25 PM, Dave Hylands <dhyla...@mozilla.com> wrote: > You stat downloading the file to the temp location. > Once the user selects the final location, you open the file in the final > location and start copying the file from the temp location to the final > location. > Eventually, your copy should catch up with your download, in which case you > can stop writing to the temp location and resume writing to the final > location.
Doesn't need to be eventually -- you should be able to seek ahead in the new file to match your location in the old file, and continue writing there immediately instead of in the old file. At least on Unix, IIRC, the OS will allow you to do this, and implicitly fill in the empty parts with zeros (without actually writing out the zero pages to disk). > In the worst case this has the disadvantage of requiring twice the amount of > disk space as the downloaded file. And twice the disk writes, and reading the whole file as well (which can be much slower than writes, because writes are buffered). On the other hand, if the temp and final locations are on different partitions, the current approach will do this anyway. Probably in most cases they're on the same partition. In theory, a filesystem that supported CoW copies of files would give you the best of both worlds, but no filesystem that our users commonly use does yet, right? _______________________________________________ dev-platform mailing list dev-platform@lists.mozilla.org https://lists.mozilla.org/listinfo/dev-platform