From fa690de1d64d21eb436e22397526408e4ba49066 Mon Sep 17 00:00:00 2001 From: csoler Date: Fri, 4 Nov 2011 21:29:51 +0000 Subject: [PATCH] small bug fixes about CRC32 verification when the file is actually complete. git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@4662 b45a01b8-16f6-495d-af2f-9b41ad6348cc --- libretroshare/src/ft/ftchunkmap.cc | 2 +- libretroshare/src/ft/ftfilecreator.cc | 3 +-- libretroshare/src/ft/fttransfermodule.cc | 5 ++++- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/libretroshare/src/ft/ftchunkmap.cc b/libretroshare/src/ft/ftchunkmap.cc index b40287633..33134091c 100644 --- a/libretroshare/src/ft/ftchunkmap.cc +++ b/libretroshare/src/ft/ftchunkmap.cc @@ -352,7 +352,7 @@ void ChunkMap::setPeerAvailabilityMap(const std::string& peer_id,const Compresse uint32_t ChunkMap::sizeOfChunk(uint32_t cid) const { if(cid == _map.size()-1) - return _file_size - (_map.size()-1)*_chunk_size ; + return _file_size - cid*_chunk_size ; else return _chunk_size ; } diff --git a/libretroshare/src/ft/ftfilecreator.cc b/libretroshare/src/ft/ftfilecreator.cc index d0f17abfe..9ad43f026 100644 --- a/libretroshare/src/ft/ftfilecreator.cc +++ b/libretroshare/src/ft/ftfilecreator.cc @@ -653,8 +653,7 @@ bool ftFileCreator::crossCheckChunkMap(const CRC32Map& ref,uint32_t& bad_chunks, delete[] buff ; - if(bad_chunks > 0) - chunkMap.setAvailabilityMap(map) ; + chunkMap.setAvailabilityMap(map) ; } closeFile() ; return true ; diff --git a/libretroshare/src/ft/fttransfermodule.cc b/libretroshare/src/ft/fttransfermodule.cc index 7b395fe00..9ab4b1c11 100644 --- a/libretroshare/src/ft/fttransfermodule.cc +++ b/libretroshare/src/ft/fttransfermodule.cc @@ -744,7 +744,10 @@ bool ftTransferModule::checkCRC() } else { - mFlag = FT_TM_FLAG_COMPLETE ; + // We do as if the file is not complete. This way, it finishes properly. + // + mFlag = FT_TM_FLAG_DOWNLOADING ; + mFileStatus.stat = ftFileStatus::PQIFILE_DOWNLOADING; #ifdef FT_DEBUG std::cerr << "ftTransferModule::checkCRC(): Done. CRC check is ok, file is complete." << std::endl ; #endif