summaryrefslogtreecommitdiff
path: root/src/DefaultBtProgressInfoFile.h
diff options
context:
space:
mode:
authorTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2015-11-10 23:02:21 +0900
committerTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2015-11-10 23:02:21 +0900
commit269520ee69e2306eaf792ccff916ba5486d2bb5f (patch)
treeab31cea457c60a3a351073e6bf74cbc89ca37139 /src/DefaultBtProgressInfoFile.h
parent5ccd5b6953c95986407a735a41e8c36cf05944d1 (diff)
Don't write control file if content is not changed from previous one
This is desirable so that we don't have to wake up disk if control file is not changed, and it is not have to be written again. We use the same method (SHA1 hash) to check the content is the same. The limitation is the hash is stored in memory, so we have to write the first time in each session. See GH-382
Diffstat (limited to 'src/DefaultBtProgressInfoFile.h')
-rw-r--r--src/DefaultBtProgressInfoFile.h7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/DefaultBtProgressInfoFile.h b/src/DefaultBtProgressInfoFile.h
index 28175e47..33a28044 100644
--- a/src/DefaultBtProgressInfoFile.h
+++ b/src/DefaultBtProgressInfoFile.h
@@ -46,6 +46,7 @@ class PieceStorage;
class PeerStorage;
class BtRuntime;
class Option;
+class IOFile;
class DefaultBtProgressInfoFile : public BtProgressInfoFile {
private:
@@ -57,8 +58,14 @@ private:
#endif // ENABLE_BITTORRENT
const Option* option_;
std::string filename_;
+ // Last SHA1 digest value of the content written. Initially, this
+ // is empty string. This is used to avoid to write same content
+ // repeatedly, which could wake up disk that may be sleeping.
+ std::string lastDigest_;
bool isTorrentDownload();
+ void save(IOFile& fp);
+
public:
DefaultBtProgressInfoFile(const std::shared_ptr<DownloadContext>& btContext,
const std::shared_ptr<PieceStorage>& pieceStorage,