aboutsummaryrefslogtreecommitdiffstats
path: root/storage/filesystem/internal/index/index.go
diff options
context:
space:
mode:
authorMáximo Cuadros <mcuadros@gmail.com>2016-09-06 01:56:41 +0200
committerMáximo Cuadros <mcuadros@gmail.com>2016-09-06 01:56:41 +0200
commitae2b10d50da5455b382ab9d543be4fe859afe9e0 (patch)
tree58cf3247a7283769c77df945f1be9a5d70e65a69 /storage/filesystem/internal/index/index.go
parent0b7aa259fe3da2236952843fe46db62bdee395eb (diff)
downloadgo-git-ae2b10d50da5455b382ab9d543be4fe859afe9e0.tar.gz
storage: filesystem idx generation (wip)
Diffstat (limited to 'storage/filesystem/internal/index/index.go')
-rw-r--r--storage/filesystem/internal/index/index.go21
1 files changed, 10 insertions, 11 deletions
diff --git a/storage/filesystem/internal/index/index.go b/storage/filesystem/internal/index/index.go
index 233dcbd..d33533e 100644
--- a/storage/filesystem/internal/index/index.go
+++ b/storage/filesystem/internal/index/index.go
@@ -34,50 +34,49 @@ func NewFromIdx(r io.Reader) (Index, error) {
}
// NewFrompackfile returns a new index from a packfile reader.
-func NewFromPackfile(rs io.ReadSeeker) (Index, error) {
+func NewFromPackfile(rs io.ReadSeeker) (Index, core.Hash, error) {
s := packfile.NewSeekable(rs)
return newFromPackfile(rs, s)
}
-func NewFromPackfileInMemory(rs io.Reader) (Index, error) {
+func NewFromPackfileInMemory(rs io.Reader) (Index, core.Hash, error) {
s := packfile.NewStream(rs)
return newFromPackfile(rs, s)
}
-func newFromPackfile(r io.Reader, s packfile.ReadRecaller) (Index, error) {
+func newFromPackfile(r io.Reader, s packfile.ReadRecaller) (Index, core.Hash, error) {
index := make(Index)
p := packfile.NewParser(s)
count, err := p.ReadHeader()
if err != nil {
- return nil, err
+ return nil, core.ZeroHash, err
}
for i := 0; i < int(count); i++ {
offset, err := s.Offset()
if err != nil {
- return nil, err
+ return nil, core.ZeroHash, err
}
obj := &core.MemoryObject{}
if err := p.FillObject(obj); err != nil {
- return nil, err
+ return nil, core.ZeroHash, err
}
err = s.Remember(offset, obj)
if err != nil {
- return nil, err
+ return nil, core.ZeroHash, err
}
if err = index.Set(obj.Hash(), offset); err != nil {
- return nil, err
+ return nil, core.ZeroHash, err
}
}
//The trailer records 20-byte SHA-1 checksum of all of the above.
- p.ReadHash()
-
- return index, nil
+ hash, err := p.ReadHash()
+ return index, hash, err
}
// Get returns the offset that an object has the packfile.