Compare commits

..

No commits in common. "c9c4fc65e70d810ac2108649db73171a2353ba73" and "0df093318790ee971cbdaf6518b4e904399327ae" have entirely different histories.

View file

@ -9,7 +9,6 @@ import (
"google.golang.org/grpc/status"
"google.golang.org/protobuf/types/known/emptypb"
"io"
"os"
)
func (s *TesterServer) CreateProblem(server problemv1.ProblemService_CreateProblemServer) error {
@ -37,12 +36,7 @@ func (s *TesterServer) CreateProblem(server problemv1.ProblemService_CreateProbl
ch := readChunks(ctx, server)
err = writeChunks(ctx, ch) // temp stub
if err != nil {
return err // FIXME
}
id, err := s.problemService.CreateProblem(ctx, p, nil) // FIXME
id, err := s.problemService.CreateProblem(ctx, p, ch)
if err != nil {
return status.Errorf(codes.Unknown, "") // FIXME
}
@ -57,28 +51,6 @@ func (s *TesterServer) CreateProblem(server problemv1.ProblemService_CreateProbl
return nil
}
func writeChunks(ctx context.Context, chunks <-chan []byte) error {
// FIXME: use ctx?
f, err := os.Create("out.txt") // FIXME: uuidv4 as initial temp name?
if err != nil {
return err
}
defer f.Close()
var off int64 = 0
for chunk := range chunks {
_, err = f.WriteAt(chunk, off)
if err != nil {
return err
}
off += int64(len(chunk))
}
// TODO: rename file to its hash
return nil
}
func readChunks(ctx context.Context, server problemv1.ProblemService_CreateProblemServer) <-chan []byte {
ch := make(chan []byte)