MCPcopy Create free account
hub / github.com/bcspragu/logseq-sync / getFiles

Method getFiles

cmd/server/main.go:750–778  ·  view source on GitHub ↗
(ctx context.Context, req *getFilesRequest)

Source from the content-addressed store, hash-verified

748}
749
750func (s *server) getFiles(ctx context.Context, req *getFilesRequest) (*getFilesResponse, error) {
751 userID, err := s.getUserID(ctx)
752 if err != nil {
753 return nil, httperr.Unauthorized("failed to load user ID: %w", err)
754 }
755
756 gID := db.GraphID(req.GraphUUID)
757 if _, err := s.db.Graph(ctx, gID); db.IsNotExists(err) {
758 return nil, httperr.NotFound("graph %q wasn't found", req.GraphUUID)
759 } else if err != nil {
760 return nil, httperr.Internal("failed to load graph: %w", err)
761 }
762
763 out := make(map[string]string)
764 // TODO: Consider checking to see if these are valid, though there's no harm in
765 // signing a URL for a non-existent blob.
766 for _, id := range req.Files {
767 key := path.Join(string(userID), string(gID), id)
768 signed, err := s.blob.SignedDownloadURL(ctx, key, 5*time.Minute)
769 if err != nil {
770 return nil, httperr.Internal("failed to sign URL: %w", err)
771 }
772 out[id] = signed
773 }
774
775 return &getFilesResponse{
776 PresignedFileURLs: out,
777 }, nil
778}
779
780type getTempCredentialRequest struct{}
781

Callers

nothing calls this directly

Calls 8

getUserIDMethod · 0.95
UnauthorizedFunction · 0.92
GraphIDTypeAlias · 0.92
IsNotExistsFunction · 0.92
NotFoundFunction · 0.92
InternalFunction · 0.92
GraphMethod · 0.65
SignedDownloadURLMethod · 0.65

Tested by

no test coverage detected