HasEncodedObject returns nil if the object exists, without actually reading the object data from storage.
(h plumbing.Hash)
| 162 | // HasEncodedObject returns nil if the object exists, without actually |
| 163 | // reading the object data from storage. |
| 164 | func (s *ObjectStorage) HasEncodedObject(h plumbing.Hash) (err error) { |
| 165 | // Check unpacked objects |
| 166 | f, err := s.dir.Object(h) |
| 167 | if err != nil { |
| 168 | if !os.IsNotExist(err) { |
| 169 | return err |
| 170 | } |
| 171 | // Fall through to check packed objects. |
| 172 | } else { |
| 173 | defer ioutil.CheckClose(f, &err) |
| 174 | return nil |
| 175 | } |
| 176 | |
| 177 | // Check packed objects. |
| 178 | if err := s.requireIndex(); err != nil { |
| 179 | return err |
| 180 | } |
| 181 | _, _, offset := s.findObjectInPackfile(h) |
| 182 | if offset == -1 { |
| 183 | return plumbing.ErrObjectNotFound |
| 184 | } |
| 185 | return nil |
| 186 | } |
| 187 | |
| 188 | func (s *ObjectStorage) encodedObjectSizeFromUnpacked(h plumbing.Hash) ( |
| 189 | size int64, err error) { |
nothing calls this directly
no test coverage detected