megatools
megatools copied to clipboard
(posix_)fallocate where possible and sane
Telling the file system how big a file will be enables it to better place files on disk, avoid fragmentation, etc.
*nix have a mechanism to effectively reserve a file of a certain size in the posix_fallocate
or linux specific fallocate
APIs.
New file system will allocate a file almost instantly. However, "old" file systems like ext3 will actually write zeros, but who still uses ext3, r-right?!
Windows has no equivalent API...
Sadly, this would throw off the resume logic, which depends on the size of a file to determine how much data was already downloaded and where to resume after user cancels and restarts the process.
Oh right, I remember disabling resume for that reason... still would be nice to have, tho that would mean tracking resume information explicitly some place else.