mirror of
https://github.com/kopia/kopia.git
synced 2026-01-26 23:38:04 -05:00
store entire rootEntry on snapshot nmanifest format 'snapshot list' consistently for both root and nested items
37 lines
663 B
Go
37 lines
663 B
Go
package dir
|
|
|
|
import (
|
|
"bufio"
|
|
"io"
|
|
|
|
"github.com/kopia/kopia/fs"
|
|
"github.com/kopia/kopia/internal/jsonstream"
|
|
)
|
|
|
|
var directoryStreamType = "kopia:directory"
|
|
|
|
// ReadEntries reads all the Entry from the specified reader.
|
|
func ReadEntries(r io.Reader) ([]*Entry, *fs.DirectorySummary, error) {
|
|
var summ fs.DirectorySummary
|
|
psr, err := jsonstream.NewReader(bufio.NewReader(r), directoryStreamType, &summ)
|
|
if err != nil {
|
|
return nil, nil, err
|
|
}
|
|
var entries []*Entry
|
|
for {
|
|
e := &Entry{}
|
|
err := psr.Read(e)
|
|
if err == io.EOF {
|
|
break
|
|
}
|
|
|
|
if err != nil {
|
|
return nil, nil, err
|
|
}
|
|
|
|
entries = append(entries, e)
|
|
}
|
|
|
|
return entries, &summ, nil
|
|
}
|