lib/scanner: Recheck file size and modification time after hashing (ref #3440)

To catch the case where the file changed. Also make sure we never let a
size-vs-blocklist mismatch slip through.

GitHub-Pull-Request: https://github.com/syncthing/syncthing/pull/3443
This commit is contained in:
Jakob Borg
2016-07-26 08:51:39 +00:00
parent 2a6f164923
commit 7aaa1dd8a3
6 changed files with 51 additions and 19 deletions

View File

@@ -29,7 +29,7 @@ func Blocks(r io.Reader, blocksize int, sizehint int64, counter Counter) ([]prot
var blocks []protocol.BlockInfo
var hashes, thisHash []byte
if sizehint > 0 {
if sizehint >= 0 {
// Allocate contiguous blocks for the BlockInfo structures and their
// hashes once and for all, and stick to the specified size.
r = io.LimitReader(r, sizehint)