From da431033840850b848ac1106d913a9de742e2575 Mon Sep 17 00:00:00 2001 From: Kevin Atkinson Date: Fri, 6 May 2016 03:58:00 -0400 Subject: [PATCH] Report an error when trying to use "--no-copy" when daemon is online. License: MIT Signed-off-by: Kevin Atkinson --- commands/files/adv_reader.go | 11 ++++++++--- commands/files/readerfile.go | 3 ++- core/coreunix/add.go | 9 ++++++--- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/commands/files/adv_reader.go b/commands/files/adv_reader.go index a0a8aebb25ab..97ee93138851 100644 --- a/commands/files/adv_reader.go +++ b/commands/files/adv_reader.go @@ -1,6 +1,7 @@ package files import ( + "errors" "io" ) @@ -9,7 +10,7 @@ import ( type AdvReader interface { io.Reader ExtraInfo() ExtraInfo - SetExtraInfo(inf ExtraInfo) + SetExtraInfo(inf ExtraInfo) error } type ExtraInfo interface { @@ -38,9 +39,13 @@ type advReaderAdapter struct { io.Reader } -func (advReaderAdapter) ExtraInfo() ExtraInfo { return nil } +func (advReaderAdapter) ExtraInfo() ExtraInfo { + return nil +} -func (advReaderAdapter) SetExtraInfo(_ ExtraInfo) {} +func (advReaderAdapter) SetExtraInfo(_ ExtraInfo) error { + return errors.New("Reader does not support setting ExtraInfo.") +} func AdvReaderAdapter(r io.Reader) AdvReader { switch t := r.(type) { diff --git a/commands/files/readerfile.go b/commands/files/readerfile.go index 27c5519e4942..e18423619a5b 100644 --- a/commands/files/readerfile.go +++ b/commands/files/readerfile.go @@ -41,8 +41,9 @@ func (f *ReaderFile) ExtraInfo() ExtraInfo { return f.baseInfo.Clone(f.offset) } -func (f *ReaderFile) SetExtraInfo(info ExtraInfo) { +func (f *ReaderFile) SetExtraInfo(info ExtraInfo) error { f.baseInfo = info + return nil } func (f *ReaderFile) Read(p []byte) (int, error) { diff --git a/core/coreunix/add.go b/core/coreunix/add.go index cefe7078d1cb..b288f1dbaecf 100644 --- a/core/coreunix/add.go +++ b/core/coreunix/add.go @@ -109,7 +109,10 @@ type Adder struct { // Perform the actual add & pin locally, outputting results to reader func (adder Adder) add(reader files.AdvReader) (*dag.Node, error) { if adder.AddOpts != nil { - reader.SetExtraInfo(files.PosInfoWaddOpts{reader.ExtraInfo(), adder.AddOpts}) + err := reader.SetExtraInfo(files.PosInfoWaddOpts{reader.ExtraInfo(), adder.AddOpts}) + if err != nil { + return nil, err + } } chnk, err := chunk.FromString(reader, adder.Chunker) if err != nil { @@ -542,6 +545,6 @@ func (i *progressReader) ExtraInfo() files.ExtraInfo { return i.reader.ExtraInfo() } -func (i *progressReader) SetExtraInfo(info files.ExtraInfo) { - i.reader.SetExtraInfo(info) +func (i *progressReader) SetExtraInfo(info files.ExtraInfo) error { + return i.reader.SetExtraInfo(info) }