When the directory is changed via aria2.changeOption RPC method, we
directly change first FileEntry's path using FileEntry::setPath(). If
there is no PREF_OUT option is given, basically file name is unknown,
so we just set empty string and let the next run determine the correct
file name and new directory is applied there. But previous code does
not reset length property of FileEntry, so the unexpected code path is
taken when unpaused and its path expects path is not empty string.
This commit fixes this issue by setting length to 0 using
FileEntry::setLength().
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.
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.
In my quest to explore the code and understand it, why not clean it up
in the progress. Most formatting provided by clang-format. ;)
Aside from formatting, also extracted some method and unnested some
control structs.
Previously we disabled conditional-get if file part is missing in URI.
But we use constant string "index.html" in this case, so we can do the
same to determine the modification time. In this patch, if we have
file part in URI, we are not going to set absolute file path in
FileEntry, since it prevents content-disposition from working.
rst2html is required to produce README.html from README.rst. We
include generated README.html to distribution. And rst2html is not
required when compiling sources in distribution and always README.html
is available.
This change should make token validation more resilient to:
- timing attacks (constant time array compare)
- brute-force/dictionary attacks (PBKDF2)
Closes#220