summaryrefslogtreecommitdiff
path: root/src/SessionSerializer.h
diff options
context:
space:
mode:
authorTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2014-05-31 16:14:33 +0900
committerTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2014-05-31 16:19:57 +0900
commit631f37433a8fda03eb057e9f01e2811111c60d5e (patch)
tree5423c539ab253a6249b0bce5e42ba6fe69b0c45d /src/SessionSerializer.h
parent998fba3264c1e896a249f140cb6060cc35c7d6bc (diff)
Save session only when there is change since the last serialization
This is a slight optimization not to cause useless disk access. This only applies to saving session automatically (see --save-session-interval). aria2.saveSession and serialization at the end of the session are always performed as before. When serialization, we first check that whether there is any change since the last serialization. To do this, we first calculate hash value of serialized content without writing into file. Then compare this value to the value of last serialization. If they do not match, perform serialization.
Diffstat (limited to 'src/SessionSerializer.h')
-rw-r--r--src/SessionSerializer.h4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/SessionSerializer.h b/src/SessionSerializer.h
index c3493edc..c9dbe29e 100644
--- a/src/SessionSerializer.h
+++ b/src/SessionSerializer.h
@@ -57,6 +57,10 @@ public:
SessionSerializer(RequestGroupMan* requestGroupMan);
bool save(const std::string& filename) const;
+
+ // Calculates and returns SHA1 hash of the contents being
+ // serialized.
+ std::string calculateHash() const;
};
} // namespace aria2