summaryrefslogtreecommitdiff
path: root/src/Piece.h
diff options
context:
space:
mode:
authorTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2014-07-12 16:52:01 +0900
committerTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2014-07-12 17:01:46 +0900
commit3aaa5a7344ef631998df9a9c2bd6cf4fbca11ac8 (patch)
treea2cb25784f084529ca1eac1db2d04bb2fdc2635c /src/Piece.h
parent620be59b1e04670fed73f0a914065f7df2ec3535 (diff)
Fix file length information in RPC response when length > 2GB is unknown
This commit fixes the bug that aria2.tellStopped RPC method returns total length and completedLength as 0 when file size is unknown in advance and turns out > 2GB in the end. This commit and addresses the performance degradation in this case.
Diffstat (limited to 'src/Piece.h')
-rw-r--r--src/Piece.h16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/Piece.h b/src/Piece.h
index 2389c3ac..c5252b67 100644
--- a/src/Piece.h
+++ b/src/Piece.h
@@ -62,9 +62,9 @@ private:
size_t index_;
- int32_t length_;
+ int64_t length_;
int32_t blockLength_;
- int32_t nextBegin_;
+ int64_t nextBegin_;
bool usedBySegment_;
@@ -75,7 +75,7 @@ public:
static const int32_t BLOCK_LENGTH = 16*1024;
Piece();
- Piece(size_t index, int32_t length, int32_t blockLength = BLOCK_LENGTH);
+ Piece(size_t index, int64_t length, int32_t blockLength = BLOCK_LENGTH);
~Piece();
@@ -127,9 +127,9 @@ public:
void setIndex(size_t index) { index_ = index; }
- int32_t getLength() const { return length_; }
+ int64_t getLength() const { return length_; }
- void setLength(int32_t length) { length_ = length; }
+ void setLength(int64_t length) { length_ = length; }
const unsigned char* getBitfield() const;
@@ -145,14 +145,14 @@ public:
bool isBlockUsed(size_t index) const;
// Calculates completed length
- int32_t getCompletedLength();
+ int64_t getCompletedLength();
void setHashType(const std::string& hashType);
// Updates hash value. This function compares begin and private variable
// nextBegin_ and only when they are equal, hash is updated eating data and
// returns true. Otherwise returns false.
- bool updateHash(int32_t begin, const unsigned char* data, size_t dataLength);
+ bool updateHash(int64_t begin, const unsigned char* data, size_t dataLength);
bool isHashCalculated() const;
@@ -171,7 +171,7 @@ public:
/**
* Loses current bitfield state.
*/
- void reconfigure(int32_t length);
+ void reconfigure(int64_t length);
void addUser(cuid_t cuid);
void removeUser(cuid_t cuid);