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