// parameter when retrieving the collection record).
var ErrNoManifest = errors.New("Collection has no manifest")
-// CollectionFileReader returns a Reader that reads file content from
-// a collection. The filename must be given relative to the root of
-// the collection, without a leading "./".
+// CollectionFileReader returns a Reader that reads content from a single file
+// in the collection. The filename must be relative to the root of the
+// collection. A leading prefix of "/" or "./" in the filename is ignored.
func (kc *KeepClient) CollectionFileReader(collection map[string]interface{}, filename string) (Reader, error) {
mText, ok := collection["manifest_text"].(string)
if !ok {
for _, testCase := range []rdrTest{
{mt: mt, f: "zzzz", want: os.ErrNotExist},
{mt: mt, f: "frob", want: os.ErrNotExist},
- {mt: mt, f: "/segmented/frob", want: os.ErrNotExist},
- {mt: mt, f: "./segmented/frob", want: os.ErrNotExist},
- {mt: mt, f: "/f", want: os.ErrNotExist},
- {mt: mt, f: "./f", want: os.ErrNotExist},
- {mt: mt, f: "foo bar//baz", want: os.ErrNotExist},
+ {mt: mt, f: "/segmented/frob", want: "frob"},
+ {mt: mt, f: "./segmented/frob", want: "frob"},
+ {mt: mt, f: "/f", want: "f"},
+ {mt: mt, f: "./f", want: "f"},
+ {mt: mt, f: "foo bar//baz", want: "foo"},
{mt: mt, f: "foo/zero", want: ""},
{mt: mt, f: "zero@0", want: ""},
{mt: mt, f: "zero@1", want: ""},