From 4246e7602f1b7764a94df9c75ac5ccc97ef934f8 Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Sun, 30 Nov 2014 22:16:34 +0100 Subject: [PATCH] Store empty list of blobs for empty files --- archiver.go | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/archiver.go b/archiver.go index 85bddc2af..0870ca248 100644 --- a/archiver.go +++ b/archiver.go @@ -171,14 +171,19 @@ func (arch *Archiver) SaveFile(node *Node) error { return arrar.Annotate(err, "SaveFile() read small file") } - blob, err := arch.ch.Save(backend.Data, buf[:n]) - if err != nil { - return arrar.Annotate(err, "SaveFile() save chunk") + if err == io.EOF { + // use empty blob list for empty files + blobs = Blobs{} + } else { + blob, err := arch.ch.Save(backend.Data, buf[:n]) + if err != nil { + return arrar.Annotate(err, "SaveFile() save chunk") + } + + arch.update(arch.SaveStats, Stats{Bytes: blob.Size}) + + blobs = Blobs{blob} } - - arch.update(arch.SaveStats, Stats{Bytes: blob.Size}) - - blobs = Blobs{blob} } else { // else store all chunks chnker := chunker.New(file)