Skip to content

Commit

Permalink
Report an error when trying to use "--no-copy" when daemon is online.
Browse files Browse the repository at this point in the history
License: MIT
Signed-off-by: Kevin Atkinson <[email protected]>
  • Loading branch information
kevina committed May 6, 2016
1 parent 0311da6 commit da43103
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
11 changes: 8 additions & 3 deletions commands/files/adv_reader.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package files

import (
"errors"
"io"
)

Expand All @@ -9,7 +10,7 @@ import (
type AdvReader interface {
io.Reader
ExtraInfo() ExtraInfo
SetExtraInfo(inf ExtraInfo)
SetExtraInfo(inf ExtraInfo) error
}

type ExtraInfo interface {
Expand Down Expand Up @@ -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) {
Expand Down
3 changes: 2 additions & 1 deletion commands/files/readerfile.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
9 changes: 6 additions & 3 deletions core/coreunix/add.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
}

0 comments on commit da43103

Please sign in to comment.