(ctx context.Context, req *getAllFilesRequest)
| 674 | } |
| 675 | |
| 676 | func (s *server) getAllFiles(ctx context.Context, req *getAllFilesRequest) (*getAllFilesResponse, error) { |
| 677 | gID := db.GraphID(req.GraphUUID) |
| 678 | |
| 679 | // TODO: We definitely want to actually use the built in pagination here, need to figure out how the real API does it (e.g. batch size, token format, etc) |
| 680 | mds, err := s.db.AllFileMeta(ctx, gID) |
| 681 | if err != nil { |
| 682 | return nil, httperr.Internal("failed to load batch file meta: %w", err) |
| 683 | } |
| 684 | |
| 685 | userID, err := s.getUserID(ctx) |
| 686 | if err != nil { |
| 687 | return nil, httperr.Unauthorized("failed to load user ID: %w", err) |
| 688 | } |
| 689 | |
| 690 | out := []getAllFilesResponseObject{} |
| 691 | for _, md := range mds { |
| 692 | out = append(out, getAllFilesResponseObject{ |
| 693 | Key: path.Join(string(userID), string(gID), string(md.ID)), |
| 694 | Checksum: string(md.Checksum), |
| 695 | LastModified: md.LastModifiedAt.UnixMilli(), |
| 696 | Size: md.Size, |
| 697 | Txid: int64(md.LastModifiedTX), |
| 698 | }) |
| 699 | } |
| 700 | |
| 701 | return &getAllFilesResponse{ |
| 702 | Objects: out, |
| 703 | NextContinuationToken: "", // TODO: See above |
| 704 | }, nil |
| 705 | } |
| 706 | |
| 707 | type getTxidRequest struct { |
| 708 | GraphUUID string `json:"GraphUUID"` |
nothing calls this directly
no test coverage detected