| 156 | } |
| 157 | |
| 158 | func (d *DB) BatchFileMeta(_ context.Context, id db.GraphID, fIDs []db.FileID) (map[db.FileID]*db.FileMeta, error) { |
| 159 | g, ok := d.graphs[id] |
| 160 | if !ok { |
| 161 | return nil, db.NotExists("graph", id) |
| 162 | } |
| 163 | |
| 164 | out := make(map[db.FileID]*db.FileMeta) |
| 165 | for _, fID := range fIDs { |
| 166 | mds, ok := g.metas[fID] |
| 167 | if !ok { |
| 168 | out[fID] = nil |
| 169 | continue |
| 170 | } |
| 171 | if len(mds) < 1 { |
| 172 | // Note: This indicates some sort of logic error, not client error |
| 173 | return nil, fmt.Errorf("no file metadata history found for %q", fID) |
| 174 | } |
| 175 | // Get the latest, which is the last one |
| 176 | out[fID] = mds[len(mds)-1] |
| 177 | } |
| 178 | return out, nil |
| 179 | } |
| 180 | |
| 181 | func (d *DB) AllFileMeta(_ context.Context, id db.GraphID) ([]*db.FileMeta, error) { |
| 182 | g, ok := d.graphs[id] |