1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2025-03-12 07:03:44 +00:00

(trunk libT) #2228: transmission should learn to truncate files on updating torrents

This commit is contained in:
Charles Kerr 2009-06-21 07:53:51 +00:00
parent ef9896e223
commit 587ddb48f0

View file

@ -342,6 +342,15 @@ TrOpenFile( int i,
return err;
}
/* If the file already exists and it's too large, truncate it.
* This is a fringe case that happens if a torrent's been updated
* and one of the updated torrent's files is smaller.
* http://trac.transmissionbt.com/ticket/2228
* https://bugs.launchpad.net/ubuntu/+source/transmission/+bug/318249
*/
if( alreadyExisted && ( desiredFileSize < (uint64_t)sb.st_size ) )
ftruncate( file->fd, desiredFileSize );
if( doWrite && !alreadyExisted && ( preallocationMode == TR_PREALLOCATE_SPARSE ) )
preallocateFileSparse( file->fd, desiredFileSize );