mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-02 22:25:04 -04:00
fixed bug in display of upload progress
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@5228 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
be177ecb27
commit
8ef3d851de
2 changed files with 21 additions and 10 deletions
|
@ -355,13 +355,26 @@ class CompressedChunkMap
|
|||
|
||||
static uint32_t getCompressedSize(uint32_t size) { return (size>>5) + !!(size&31) ; }
|
||||
|
||||
uint32_t filledChunks(uint32_t nbchks)
|
||||
uint32_t filledChunks(uint32_t nbchks) const
|
||||
{
|
||||
uint32_t res = 0 ;
|
||||
for(uint32_t i=0;i<std::min(nbchks,(uint32_t)_map.size()*32);++i)
|
||||
res += operator[](i) ;
|
||||
return res ;
|
||||
}
|
||||
uint64_t computeProgress(uint64_t total_size,uint32_t chunk_size) const
|
||||
{
|
||||
if(total_size == 0)
|
||||
return 0 ;
|
||||
|
||||
uint32_t nbchks = (uint32_t)((total_size + (uint64_t)chunk_size - 1) / (uint64_t)chunk_size) ;
|
||||
uint32_t residue = total_size%chunk_size ;
|
||||
|
||||
if(residue && operator[](nbchks-1))
|
||||
return (filledChunks(nbchks)-1)*chunk_size + (total_size%chunk_size) ;
|
||||
else
|
||||
return filledChunks(nbchks)*chunk_size ;
|
||||
}
|
||||
inline bool operator[](uint32_t i) const { return (_map[i >> 5] & (1 << (i & 31))) > 0 ; }
|
||||
|
||||
inline void set(uint32_t j) { _map[j >> 5] |= (1 << (j & 31)) ; }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue