LazyWriter returns a lazy ObjectWriter that is bound to a DotGit file. It first write the header passing on the object type and size, so that the object contents can be written later, without the need to create a MemoryObject and buffering its entire contents into memory.
()
| 151 | // that the object contents can be written later, without the need to |
| 152 | // create a MemoryObject and buffering its entire contents into memory. |
| 153 | func (s *ObjectStorage) LazyWriter() (w io.WriteCloser, wh func(typ plumbing.ObjectType, sz int64) error, err error) { |
| 154 | ow, err := s.dir.NewObject() |
| 155 | if err != nil { |
| 156 | return nil, nil, err |
| 157 | } |
| 158 | |
| 159 | return ow, ow.WriteHeader, nil |
| 160 | } |
| 161 | |
| 162 | // HasEncodedObject returns nil if the object exists, without actually |
| 163 | // reading the object data from storage. |