aboutsummaryrefslogtreecommitdiffstats
path: root/storage/filesystem/object.go
diff options
context:
space:
mode:
authorMáximo Cuadros <mcuadros@gmail.com>2016-09-11 20:35:06 +0200
committerMáximo Cuadros <mcuadros@gmail.com>2016-09-11 20:35:06 +0200
commit58fe211f1b0e4863b425542d2fad15803276fd66 (patch)
treec200b6317b7b1c77c312faa411ab39e6e4468967 /storage/filesystem/object.go
parent6f1d1e00a7c615209cf6b25e314d033bda3b5d09 (diff)
downloadgo-git-58fe211f1b0e4863b425542d2fad15803276fd66.tar.gz
format: packfile fix ReadObjectAt without decode
Diffstat (limited to 'storage/filesystem/object.go')
-rw-r--r--storage/filesystem/object.go15
1 files changed, 14 insertions, 1 deletions
diff --git a/storage/filesystem/object.go b/storage/filesystem/object.go
index 0b82524..dc21d0b 100644
--- a/storage/filesystem/object.go
+++ b/storage/filesystem/object.go
@@ -67,7 +67,19 @@ func (s *ObjectStorage) NewObject() core.Object {
// Writer method not supported on Memory storage
func (s *ObjectStorage) Writer() (io.WriteCloser, error) {
- return s.dir.NewObjectPack()
+ w, err := s.dir.NewObjectPack()
+ if err != nil {
+ return nil, err
+ }
+
+ w.Notify = func(h core.Hash, idx idxfile.Idxfile) {
+ s.index[h] = make(index)
+ for _, e := range idx.Entries {
+ s.index[h][e.Hash] = int64(e.Offset)
+ }
+ }
+
+ return w, nil
}
// Set adds a new object to the storage. As this functionality is not
@@ -150,6 +162,7 @@ func (s *ObjectStorage) getFromPackfile(h core.Hash) (core.Object, error) {
p := packfile.NewScanner(f)
d := packfile.NewDecoder(p, memory.NewStorage().ObjectStorage())
+ d.SetOffsets(s.index[pack])
return d.ReadObjectAt(offset)
}