diff --git a/libretroshare/src/ft/ftchunkmap.cc b/libretroshare/src/ft/ftchunkmap.cc index cb4d0eac2..c2348f01a 100644 --- a/libretroshare/src/ft/ftchunkmap.cc +++ b/libretroshare/src/ft/ftchunkmap.cc @@ -402,6 +402,16 @@ void ChunkMap::getChunksInfo(FileChunksInfo& info) const info.compressed_peer_availability_maps[it->first] = it->second.cmap ; } +void ChunkMap::removeFileSource(const std::string& peer_id) +{ + std::map::iterator it(_peers_chunks_availability.find(peer_id)) ; + + if(it == _peers_chunks_availability.end()) + return ; + + _peers_chunks_availability.erase(it) ; +} + void ChunkMap::getAvailabilityMap(CompressedChunkMap& compressed_map) const { compressed_map = CompressedChunkMap(_map) ; diff --git a/libretroshare/src/ft/ftchunkmap.h b/libretroshare/src/ft/ftchunkmap.h index b3a3b3227..7cbdc6484 100644 --- a/libretroshare/src/ft/ftchunkmap.h +++ b/libretroshare/src/ft/ftchunkmap.h @@ -135,6 +135,9 @@ class ChunkMap virtual void getAvailabilityMap(CompressedChunkMap& cmap) const ; void setAvailabilityMap(const CompressedChunkMap& cmap) ; + /// Removes the source availability map. The map + void removeFileSource(const std::string& peer_id) ; + /// This function fills in a plain map for a file of the given size. This /// is used to ensure that the chunk size will be consistent with the rest /// of the code. diff --git a/libretroshare/src/ft/ftcontroller.cc b/libretroshare/src/ft/ftcontroller.cc index ea09c5d85..28c7c2f77 100644 --- a/libretroshare/src/ft/ftcontroller.cc +++ b/libretroshare/src/ft/ftcontroller.cc @@ -181,6 +181,7 @@ void ftController::removeFileSource(const std::string& hash,const std::string& p if(it->first == hash) { it->second->mTransfer->removeFileSource(peer_id); + it->second->mCreator->removeFileSource(peer_id); // setPeerState(it->second.mTransfer, peer_id, rate, mConnMgr->isOnline(peer_id)); diff --git a/libretroshare/src/ft/ftfilecreator.cc b/libretroshare/src/ft/ftfilecreator.cc index 45aa44276..205390b7f 100644 --- a/libretroshare/src/ft/ftfilecreator.cc +++ b/libretroshare/src/ft/ftfilecreator.cc @@ -177,6 +177,15 @@ void ftFileCreator::removeInactiveChunks() #endif } +void ftFileCreator::removeFileSource(const std::string& peer_id) +{ + RsStackMutex stack(ftcMutex); /********** STACK LOCKED MTX ******/ +#ifdef FILE_DEBUG + std::cerr << "ftFileCreator:: removign file source " << peer_id << " from chunkmap." << std::endl ; +#endif + chunkMap.removeFileSource(peer_id) ; +} + int ftFileCreator::initializeFileAttrs() { #ifdef FILE_DEBUG diff --git a/libretroshare/src/ft/ftfilecreator.h b/libretroshare/src/ft/ftfilecreator.h index a68bba213..b11710ce7 100644 --- a/libretroshare/src/ft/ftfilecreator.h +++ b/libretroshare/src/ft/ftfilecreator.h @@ -73,6 +73,9 @@ class ftFileCreator: public ftFileProvider // void removeInactiveChunks() ; + // removes the designated file source from the chunkmap. + void removeFileSource(const std::string& peer_id) ; + // Returns the time stamp of the last data receive. time_t lastRecvTimeStamp() ; diff --git a/libretroshare/src/ft/ftfileprovider.cc b/libretroshare/src/ft/ftfileprovider.cc index 731f6ffad..4cc903313 100644 --- a/libretroshare/src/ft/ftfileprovider.cc +++ b/libretroshare/src/ft/ftfileprovider.cc @@ -217,28 +217,28 @@ void ftFileProvider::getClientMap(const std::string& peer_id,CompressedChunkMap& int ftFileProvider::initializeFileAttrs() { - #ifdef DEBUG_FT_FILE_PROVIDER - std::cerr << "ftFileProvider::initializeFileAttrs() Filename: " << file_name << std::endl; - #endif - - RsStackMutex stack(ftcMutex); /********** STACK LOCKED MTX ******/ +#ifdef DEBUG_FT_FILE_PROVIDER + std::cerr << "ftFileProvider::initializeFileAttrs() Filename: " << file_name << std::endl; +#endif + + RsStackMutex stack(ftcMutex); /********** STACK LOCKED MTX ******/ if (fd) return 1; /* - * check if the file exists - */ - + * check if the file exists + */ + { - #ifdef DEBUG_FT_FILE_PROVIDER - std::cerr << "ftFileProvider::initializeFileAttrs() trying (r+b) " << std::endl; - #endif +#ifdef DEBUG_FT_FILE_PROVIDER + std::cerr << "ftFileProvider::initializeFileAttrs() trying (r+b) " << std::endl; +#endif } /* - * attempt to open file - */ - + * attempt to open file + */ + fd = fopen64(file_name.c_str(), "rb"); if (!fd) { @@ -251,28 +251,28 @@ int ftFileProvider::initializeFileAttrs() { std::cerr << "ftFileProvider::initializeFileAttrs() Failed to open (rb): "; std::cerr << file_name << std::endl; - + /* try opening read only */ return 0; } } /* - * if it opened, find it's length + * if it opened, find it's length * move to the end - */ - - if (0 != fseeko64(fd, 0L, SEEK_END)) - { - std::cerr << "ftFileProvider::initializeFileAttrs() Seek Failed" << std::endl; - return 0; - } + */ - uint64_t recvdsize = ftello64(fd); +// if (0 != fseeko64(fd, 0L, SEEK_END)) +// { +// std::cerr << "ftFileProvider::initializeFileAttrs() Seek Failed" << std::endl; +// return 0; +// } +// +// uint64_t recvdsize = ftello64(fd); +// +//#ifdef DEBUG_FT_FILE_PROVIDER +// std::cerr << "ftFileProvider::initializeFileAttrs() File Expected Size: " << mSize << " RecvdSize: " << recvdsize << std::endl; +//#endif - #ifdef DEBUG_FT_FILE_PROVIDER - std::cerr << "ftFileProvider::initializeFileAttrs() File Expected Size: " << mSize << " RecvdSize: " << recvdsize << std::endl; - #endif - return 1; } diff --git a/libretroshare/src/turtle/p3turtle.cc b/libretroshare/src/turtle/p3turtle.cc index 91a183c81..a16d2890d 100644 --- a/libretroshare/src/turtle/p3turtle.cc +++ b/libretroshare/src/turtle/p3turtle.cc @@ -247,9 +247,9 @@ void p3turtle::autoWash() if(it == _incoming_file_hashes.end()) { - #ifdef P3TURTLE_DEBUG +#ifdef P3TURTLE_DEBUG std::cerr << "p3turtle: asked to stop monitoring file hash " << _hashes_to_remove[i] << ", but this hash is actually not handled by the turtle router." << std::endl ; - #endif +#endif continue ; } diff --git a/retroshare-gui/src/gui/FileTransferInfoWidget.cpp b/retroshare-gui/src/gui/FileTransferInfoWidget.cpp index f64a793ca..d60b07e01 100644 --- a/retroshare-gui/src/gui/FileTransferInfoWidget.cpp +++ b/retroshare-gui/src/gui/FileTransferInfoWidget.cpp @@ -187,7 +187,7 @@ void FileTransferInfoWidget::draw(const FileInfo& nfo,const FileChunksInfo& info y += block_sep ; y += text_height ; painter->setPen(QColor::fromRgb(0,0,0)) ; - painter->drawText(0,y,tr("Availability map (")+QString::number(info.compressed_peer_availability_maps.size())+ tr(" sources")+")") ; + painter->drawText(0,y,tr("Availability map (")+QString::number(info.compressed_peer_availability_maps.size())+ tr(" active sources")+")") ; y += block_sep ; // Note (for non geeks): the !! operator transforms anything positive into 1 and 0 into 0.