From 870073345b6a1425be9574b63013ae08c211ccfc Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Sat, 10 May 2014 23:38:54 +0000 Subject: [PATCH] merged sparse file fix from RC_0_16 --- ChangeLog | 1 + src/file.cpp | 8 ++++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6e8e32907..80e2ca869 100644 --- a/ChangeLog +++ b/ChangeLog @@ -50,6 +50,7 @@ * fix uTP edge case where udp socket buffer fills up * fix nagle implementation in uTP + * fixed sparse file detection on windows * fixed bug in gunzip * fix to use proxy settings when adding .torrent file from URL * fix resume file issue related to daylight savings time on windows diff --git a/src/file.cpp b/src/file.cpp index fb9e0fc7f..5f97940b7 100644 --- a/src/file.cpp +++ b/src/file.cpp @@ -1317,8 +1317,12 @@ typedef struct _FILE_ALLOCATED_RANGE_BUFFER { return true; } - // if we only have a single range in the file, we're not sparse - return returned_bytes != sizeof(FILE_ALLOCATED_RANGE_BUFFER); + // if we have more than one range in the file, we're sparse + if (returned_bytes != sizeof(FILE_ALLOCATED_RANGE_BUFFER)) { + return true; + } + + return (in.Length.QuadPart != out[0].Length.QuadPart); } #endif