Skip to content

Commit

Permalink
update go in dockerfiles, fix upload name in state, go mod tidy
Browse files Browse the repository at this point in the history
  • Loading branch information
adwski committed May 11, 2024
1 parent da5d9f4 commit 9e34ad1
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 154 deletions.
2 changes: 1 addition & 1 deletion docker/processor.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.22.1-bookworm as builder
FROM golang:1.22.3-bookworm as builder

ENV CGO_ENABLED=0 \
GOOS=linux \
Expand Down
2 changes: 1 addition & 1 deletion docker/streamer.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.22.1-bookworm as builder
FROM golang:1.22.3-bookworm as builder

ENV CGO_ENABLED=0 \
GOOS=linux \
Expand Down
2 changes: 1 addition & 1 deletion docker/uploader.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.22.1-bookworm as builder
FROM golang:1.22.3-bookworm as builder

ENV CGO_ENABLED=0 \
GOOS=linux \
Expand Down
2 changes: 1 addition & 1 deletion docker/userapi.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.22.1-bookworm as builder
FROM golang:1.22.3-bookworm as builder

ENV CGO_ENABLED=0 \
GOOS=linux \
Expand Down
2 changes: 1 addition & 1 deletion docker/videoapi.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.22.1-bookworm as builder
FROM golang:1.22.3-bookworm as builder

ENV CGO_ENABLED=0 \
GOOS=linux \
Expand Down
2 changes: 0 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ require (
github.com/golang-migrate/migrate/v4 v4.17.1
github.com/grpc-ecosystem/go-grpc-middleware/v2 v2.1.0
github.com/jackc/pgerrcode v0.0.0-20240316143900-6e2875d9b438
github.com/jackc/pgtype v1.14.0
github.com/jackc/pgx/v5 v5.5.5
github.com/json-iterator/go v1.1.12
github.com/labstack/echo-jwt/v4 v4.2.0
Expand Down Expand Up @@ -62,7 +61,6 @@ require (
github.com/hashicorp/go-multierror v1.1.1 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/jackc/pgio v1.0.0 // indirect
github.com/jackc/pgpassfile v1.0.0 // indirect
github.com/jackc/pgservicefile v0.0.0-20231201235250-de7065d80cb9 // indirect
github.com/jackc/puddle/v2 v2.2.1 // indirect
Expand Down
139 changes: 0 additions & 139 deletions go.sum

Large diffs are not rendered by default.

17 changes: 9 additions & 8 deletions internal/tool/videoapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ func (t *Tool) checkUploadPartsState(upload *Upload) (map[uint32]*pb.VideoPart,
}

func (t *Tool) uploadFileNotify(name, filePath string) {
size, err := t.prepareUpload(filePath)
size, err := t.prepareUpload(filePath, name)
if err != nil {
t.fb <- err
return
Expand Down Expand Up @@ -235,15 +235,15 @@ func (t *Tool) uploadFileNotify(name, filePath string) {
t.fb <- uploadCompleted{}
}

func (t *Tool) prepareUpload(filePath string) (uint64, error) {
func (t *Tool) prepareUpload(filePath, name string) (uint64, error) {
size, err := getFileSize(filePath)
if err != nil {
return 0, err
}
if err = t.checkQuotas(size); err != nil {
return 0, err
}
return size, t.prepareParts(filePath, size)
return size, t.prepareParts(filePath, name, size)
}

func getFileSize(filePath string) (uint64, error) {
Expand Down Expand Up @@ -296,7 +296,7 @@ func (t *Tool) createVideo(name string, size uint64, uploadParts []Part) (*pb.Vi
return cvResp, nil
}

func (t *Tool) prepareParts(filePath string, size uint64) error {
func (t *Tool) prepareParts(filePath, name string, size uint64) error {
f, err := os.Open(filePath)
if err != nil {
return fmt.Errorf("unable to open file: %w", err)
Expand All @@ -307,7 +307,8 @@ func (t *Tool) prepareParts(filePath string, size uint64) error {
if size%partSize != 0 {
partCount++
}
uploadInfo := &Upload{
uInfo := &Upload{
Name: name,
Filename: filePath,
}
for i := uint64(0); i < partCount; i++ {
Expand All @@ -318,14 +319,14 @@ func (t *Tool) prepareParts(filePath string, size uint64) error {
return fmt.Errorf("unable to calculate sha256 sum: %w", errCp)
}
}
uploadInfo.Parts = append(uploadInfo.Parts, Part{
uInfo.Parts = append(uInfo.Parts, Part{
Num: uint(i),
Size: uint(n),
Checksum: base64.StdEncoding.EncodeToString(h.Sum(nil)),
})
}
t.logger.Debug("prepared upload info", zap.Any("info", uploadInfo))
t.state.activeUserUnsafe().CurrentUpload = uploadInfo
t.logger.Debug("prepared upload info", zap.Any("info", uInfo))
t.state.activeUserUnsafe().CurrentUpload = uInfo
return t.state.persist()
}

Expand Down

0 comments on commit 9e34ad1

Please sign in to comment.