From ea2592b42b1a5b0d303538d005a07af51a418561 Mon Sep 17 00:00:00 2001 From: Alex Dedul Date: Fri, 10 Aug 2007 14:36:54 +0000 Subject: [PATCH] Re-applied patch to fix files timestamps changing when seeding. It was removed in [1425] and sync with libtorrent r1442 didn't fix that issue. --- libtorrent/src/file.cpp | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/libtorrent/src/file.cpp b/libtorrent/src/file.cpp index 515406a46..3d568d1f7 100755 --- a/libtorrent/src/file.cpp +++ b/libtorrent/src/file.cpp @@ -248,11 +248,17 @@ namespace libtorrent void set_size(size_type s) { size_type pos = tell(); - seek(s - 1); - char dummy = 0; - read(&dummy, 1); - seek(s - 1); - write(&dummy, 1); + // Only set size if current file size not equals s. + // 2 as "m" argument is to be sure seek() sets SEEK_END on + // all compilers. + if(s != seek(0, 2)) + { + seek(s - 1); + char dummy = 0; + read(&dummy, 1); + seek(s - 1); + write(&dummy, 1); + } seek(pos); }