fix copy_file when the file ends with a sparse region

This commit is contained in:
arvidn
2022-09-25 17:33:12 +02:00
committed by Arvid Norberg
parent 1f356d0550
commit 3e3fc5864b
2 changed files with 7 additions and 0 deletions

View File

@ -1,3 +1,4 @@
* fix copy_file when the file ends with a sparse region
* uTP performance, fix packet loss when sending is stalled
* fix trackers being stuck after session pause/resume
* fix bug in hash_picker with empty files

View File

@ -417,6 +417,12 @@ void copy_file(std::string const& inf, std::string const& newf, storage_error& s
if (data_start == off_t(-1))
{
int const err = errno;
// if we SEEK_DATA while the file location is past the last
// non-sparse region (i.e. the file has been truncated without
// filled in, the end of the file may be a sparse region). In
// this case there's nothing left to copy, and we're done
if (err == ENXIO) return;
// if SEEK_DATA is not supported, fall back to plain copy
if (err == ENOTSUP) break;
se.operation = operation_t::file_seek;
se.ec.assign(err, system_category());