Compare commits
No commits in common. "c9c4fc65e70d810ac2108649db73171a2353ba73" and "0df093318790ee971cbdaf6518b4e904399327ae" have entirely different histories.
c9c4fc65e7
...
0df0933187
1 changed files with 1 additions and 29 deletions
|
@ -9,7 +9,6 @@ import (
|
||||||
"google.golang.org/grpc/status"
|
"google.golang.org/grpc/status"
|
||||||
"google.golang.org/protobuf/types/known/emptypb"
|
"google.golang.org/protobuf/types/known/emptypb"
|
||||||
"io"
|
"io"
|
||||||
"os"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func (s *TesterServer) CreateProblem(server problemv1.ProblemService_CreateProblemServer) error {
|
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)
|
ch := readChunks(ctx, server)
|
||||||
|
|
||||||
err = writeChunks(ctx, ch) // temp stub
|
id, err := s.problemService.CreateProblem(ctx, p, ch)
|
||||||
if err != nil {
|
|
||||||
return err // FIXME
|
|
||||||
}
|
|
||||||
|
|
||||||
id, err := s.problemService.CreateProblem(ctx, p, nil) // FIXME
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return status.Errorf(codes.Unknown, "") // FIXME
|
return status.Errorf(codes.Unknown, "") // FIXME
|
||||||
}
|
}
|
||||||
|
@ -57,28 +51,6 @@ func (s *TesterServer) CreateProblem(server problemv1.ProblemService_CreateProbl
|
||||||
return nil
|
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 {
|
func readChunks(ctx context.Context, server problemv1.ProblemService_CreateProblemServer) <-chan []byte {
|
||||||
ch := make(chan []byte)
|
ch := make(chan []byte)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue