From 3336f2b8e7b747fed4a2ada713ada202162a3c04 Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Sun, 7 Dec 2014 13:30:16 +0100 Subject: [PATCH] Check number of bytes saved for each file --- archiver.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/archiver.go b/archiver.go index 10f388e8a..fb55be812 100644 --- a/archiver.go +++ b/archiver.go @@ -241,10 +241,17 @@ func (arch *Archiver) SaveFile(node *Node) error { } } + var bytes uint64 + node.Content = make([]backend.ID, len(blobs)) for i, blob := range blobs { node.Content[i] = blob.ID arch.bl.Insert(blob) + bytes += blob.Size + } + + if bytes != node.Size { + return fmt.Errorf("errors saving node %q: saved %d bytes, wanted %d bytes", node.path, bytes, node.Size) } return nil