(st storer.EncodedObjectStorer, prefix []byte)
| 1858 | } |
| 1859 | |
| 1860 | func expandPartialHash(st storer.EncodedObjectStorer, prefix []byte) (hashes []plumbing.Hash) { |
| 1861 | // The fast version is implemented by storage/filesystem.ObjectStorage. |
| 1862 | type fastIter interface { |
| 1863 | HashesWithPrefix(prefix []byte) ([]plumbing.Hash, error) |
| 1864 | } |
| 1865 | if fi, ok := st.(fastIter); ok { |
| 1866 | h, err := fi.HashesWithPrefix(prefix) |
| 1867 | if err != nil { |
| 1868 | return nil |
| 1869 | } |
| 1870 | return h |
| 1871 | } |
| 1872 | |
| 1873 | // Slow path. |
| 1874 | iter, err := st.IterEncodedObjects(plumbing.AnyObject) |
| 1875 | if err != nil { |
| 1876 | return nil |
| 1877 | } |
| 1878 | iter.ForEach(func(obj plumbing.EncodedObject) error { |
| 1879 | h := obj.Hash() |
| 1880 | if bytes.HasPrefix(h[:], prefix) { |
| 1881 | hashes = append(hashes, h) |
| 1882 | } |
| 1883 | return nil |
| 1884 | }) |
| 1885 | return |
| 1886 | } |
no test coverage detected