From f665be55fe832086202e54449402c1513cf4f195 Mon Sep 17 00:00:00 2001 From: unclejack Date: Tue, 4 Nov 2014 15:46:45 +0200 Subject: [PATCH] volume: stream JSON & Decode Docker-DCO-1.1-Signed-off-by: Cristian Staretu (github: unclejack) --- volumes/volume.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/volumes/volume.go b/volumes/volume.go index 73cbb3640d..d718b07d70 100644 --- a/volumes/volume.go +++ b/volumes/volume.go @@ -154,12 +154,15 @@ func (v *Volume) FromDisk() error { return err } - data, err := ioutil.ReadFile(pth) + jsonSource, err := os.Open(pth) if err != nil { return err } + defer jsonSource.Close() - return json.Unmarshal(data, v) + dec := json.NewDecoder(jsonSource) + + return dec.Decode(v) } func (v *Volume) jsonPath() (string, error) {