Skip to content

Commit

Permalink
feat(tusd): Bump tusd pkg to v2.4.0
Browse files Browse the repository at this point in the history
Signed-off-by: jkoberg <jkoberg@owncloud.com>
  • Loading branch information
kobergj committed Aug 1, 2024
1 parent c10f2ae commit c6a5c69
Show file tree
Hide file tree
Showing 18 changed files with 76 additions and 1,164 deletions.
5 changes: 5 additions & 0 deletions changelog/unreleased/bump-tusd.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Enhancement: Bump tusd to v2

Bump tusd pkg to v2.4.0

https://github.com/cs3org/reva/pull/4784
12 changes: 5 additions & 7 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ require (
github.com/pkg/errors v0.9.1
github.com/pkg/xattr v0.4.9
github.com/prometheus/alertmanager v0.26.0
github.com/prometheus/client_golang v1.18.0
github.com/prometheus/client_golang v1.19.0
github.com/rogpeppe/go-internal v1.12.0
github.com/rs/cors v1.10.1
github.com/rs/zerolog v1.32.0
Expand All @@ -79,7 +79,7 @@ require (
github.com/studio-b12/gowebdav v0.0.0-20221015232716-17255f2e7423
github.com/test-go/testify v1.1.4
github.com/thanhpk/randstr v1.0.6
github.com/tus/tusd v1.13.0
github.com/tus/tusd/v2 v2.4.0
github.com/wk8/go-ordered-map v1.0.0
go-micro.dev/v4 v4.10.2
go.etcd.io/etcd/client/v3 v3.5.12
Expand All @@ -96,7 +96,7 @@ require (
golang.org/x/sys v0.19.0
golang.org/x/term v0.18.0
golang.org/x/text v0.14.0
google.golang.org/genproto v0.0.0-20240205150955-31a09d347014
google.golang.org/genproto v0.0.0-20240213162025-012b6fc9bca9
google.golang.org/grpc v1.64.0
google.golang.org/protobuf v1.33.0
)
Expand All @@ -112,7 +112,6 @@ require (
github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/bitly/go-simplejson v0.5.0 // indirect
github.com/bmizerany/pat v0.0.0-20210406213842-e4b6760bdd6f // indirect
github.com/cenkalti/backoff/v4 v4.2.1 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/cloudflare/circl v1.3.3 // indirect
Expand Down Expand Up @@ -149,7 +148,7 @@ require (
github.com/golang/glog v1.2.0 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/google/go-querystring v1.1.0 // indirect
github.com/google/pprof v0.0.0-20211008130755-947d60d73cc0 // indirect
github.com/google/pprof v0.0.0-20211214055906-6f57359322fd // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.19.0 // indirect
github.com/hashicorp/consul/api v1.15.2 // indirect
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
Expand All @@ -170,7 +169,6 @@ require (
github.com/mattn/go-isatty v0.0.19 // indirect
github.com/mattn/go-runewidth v0.0.13 // indirect
github.com/mattn/go-tty v0.0.3 // indirect
github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0 // indirect
github.com/miekg/dns v1.1.50 // indirect
github.com/minio/highwayhash v1.0.2 // indirect
github.com/minio/md5-simd v1.1.2 // indirect
Expand All @@ -194,7 +192,7 @@ require (
github.com/pkg/term v1.2.0-beta.2 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/prometheus/client_model v0.5.0 // indirect
github.com/prometheus/common v0.45.0 // indirect
github.com/prometheus/common v0.48.0 // indirect
github.com/prometheus/procfs v0.12.0 // indirect
github.com/prometheus/statsd_exporter v0.22.8 // indirect
github.com/rivo/uniseg v0.4.2 // indirect
Expand Down
1,149 changes: 14 additions & 1,135 deletions go.sum

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion internal/http/services/owncloud/ocdav/tus.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ import (
"github.com/cs3org/reva/v2/pkg/storagespace"
"github.com/cs3org/reva/v2/pkg/utils"
"github.com/rs/zerolog"
tusd "github.com/tus/tusd/pkg/handler"
tusd "github.com/tus/tusd/v2/pkg/handler"
"go.opentelemetry.io/otel/propagation"
)

Expand Down
4 changes: 2 additions & 2 deletions pkg/ocm/storage/received/upload.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import (
"strings"

"github.com/google/uuid"
tusd "github.com/tus/tusd/pkg/handler"
tusd "github.com/tus/tusd/v2/pkg/handler"

userpb "github.com/cs3org/go-cs3apis/cs3/identity/user/v1beta1"
provider "github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1"
Expand Down Expand Up @@ -266,7 +266,7 @@ func (u *upload) GetInfo(ctx context.Context) (tusd.FileInfo, error) {
return u.Info, nil
}

func (u *upload) GetReader(ctx context.Context) (io.Reader, error) {
func (u *upload) GetReader(ctx context.Context) (io.ReadCloser, error) {
return os.Open(u.BinPath())
}

Expand Down
36 changes: 33 additions & 3 deletions pkg/rhttp/datatx/manager/tus/tus.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ package tus

import (
"context"
"log"
"net/http"
"path"
"regexp"

"github.com/pkg/errors"
tusd "github.com/tus/tusd/pkg/handler"
"github.com/rs/zerolog"
tusd "github.com/tus/tusd/v2/pkg/handler"

provider "github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1"
"github.com/cs3org/reva/v2/internal/http/services/owncloud/ocdav/net"
Expand All @@ -39,6 +39,7 @@ import (
"github.com/cs3org/reva/v2/pkg/storage"
"github.com/cs3org/reva/v2/pkg/storagespace"
"github.com/mitchellh/mapstructure"
"golang.org/x/exp/slog"
)

func init() {
Expand Down Expand Up @@ -99,7 +100,7 @@ func (m *manager) Handler(fs storage.FS) (http.Handler, error) {
config := tusd.Config{
StoreComposer: composer,
NotifyCompleteUploads: true,
Logger: log.New(appctx.GetLogger(context.Background()), "", 0),
Logger: slog.New(tusdLogger{log: appctx.GetLogger(context.Background())}), // Note: this is a noop logger
}

if m.conf.CorsEnabled {
Expand Down Expand Up @@ -222,3 +223,32 @@ func setHeaders(fs storage.FS, w http.ResponseWriter, r *http.Request) {
}
w.Header().Set(net.HeaderOCFileID, storagespace.FormatResourceID(resourceid))
}

// tusdLogger is a logger implementation (slog) for tusd that uses zerolog.
type tusdLogger struct {
log *zerolog.Logger
}

// Handle handles the record
func (l tusdLogger) Handle(_ context.Context, r slog.Record) error {
switch r.Level {
case slog.LevelDebug:
l.log.Debug().Msg(r.Message)
case slog.LevelInfo:
l.log.Info().Msg(r.Message)
case slog.LevelWarn:
l.log.Warn().Msg(r.Message)
case slog.LevelError:
l.log.Error().Msg(r.Message)
}
return nil
}

// Enabled returns true
func (l tusdLogger) Enabled(_ context.Context, _ slog.Level) bool { return true }

// WithAttrs is not implemented
func (l tusdLogger) WithAttrs(_ []slog.Attr) slog.Handler { return l }

// WithGroup is not implemented
func (l tusdLogger) WithGroup(_ string) slog.Handler { return l }
4 changes: 2 additions & 2 deletions pkg/storage/fs/cephfs/upload.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ import (
"github.com/cs3org/reva/v2/pkg/utils"
"github.com/google/uuid"
"github.com/pkg/errors"
tusd "github.com/tus/tusd/pkg/handler"
tusd "github.com/tus/tusd/v2/pkg/handler"
)

func (fs *cephfs) Upload(ctx context.Context, req storage.UploadRequest, uff storage.UploadFinishedFunc) (*provider.ResourceInfo, error) {
Expand Down Expand Up @@ -299,7 +299,7 @@ func (upload *fileUpload) GetInfo(ctx context.Context) (tusd.FileInfo, error) {
}

// GetReader returns an io.Reader for the upload
func (upload *fileUpload) GetReader(ctx context.Context) (file io.Reader, err error) {
func (upload *fileUpload) GetReader(ctx context.Context) (file io.ReadCloser, err error) {
user := upload.fs.makeUser(upload.ctx)
user.op(func(cv *cacheVal) {
file, err = cv.mount.Open(upload.binPath, os.O_RDONLY, 0)
Expand Down
4 changes: 2 additions & 2 deletions pkg/storage/fs/owncloudsql/upload.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ import (
"github.com/google/uuid"
"github.com/pkg/errors"
"github.com/rs/zerolog/log"
tusd "github.com/tus/tusd/pkg/handler"
tusd "github.com/tus/tusd/v2/pkg/handler"
)

var defaultFilePerm = os.FileMode(0664)
Expand Down Expand Up @@ -388,7 +388,7 @@ func (upload *fileUpload) WriteChunk(ctx context.Context, offset int64, src io.R
}

// GetReader returns an io.Reader for the upload
func (upload *fileUpload) GetReader(ctx context.Context) (io.Reader, error) {
func (upload *fileUpload) GetReader(ctx context.Context) (io.ReadCloser, error) {
return os.Open(upload.binPath)
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/storage/fs/posix/posix.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import (
"os"
"syscall"

tusd "github.com/tus/tusd/pkg/handler"
tusd "github.com/tus/tusd/v2/pkg/handler"
microstore "go-micro.dev/v4/store"

"github.com/cs3org/reva/v2/pkg/events"
Expand Down
2 changes: 1 addition & 1 deletion pkg/storage/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (
"io"
"net/url"

tusd "github.com/tus/tusd/pkg/handler"
tusd "github.com/tus/tusd/v2/pkg/handler"

provider "github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1"
registry "github.com/cs3org/go-cs3apis/cs3/storage/registry/v1beta1"
Expand Down
2 changes: 1 addition & 1 deletion pkg/storage/uploads.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (

userpb "github.com/cs3org/go-cs3apis/cs3/identity/user/v1beta1"
provider "github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1"
tusd "github.com/tus/tusd/pkg/handler"
tusd "github.com/tus/tusd/v2/pkg/handler"
)

// UploadFinishedFunc is a callback function used in storage drivers to indicate that an upload has finished
Expand Down
2 changes: 1 addition & 1 deletion pkg/storage/utils/decomposedfs/decomposedfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ import (
"github.com/cs3org/reva/v2/pkg/utils"
"github.com/jellydator/ttlcache/v2"
"github.com/pkg/errors"
tusd "github.com/tus/tusd/pkg/handler"
tusd "github.com/tus/tusd/v2/pkg/handler"
microstore "go-micro.dev/v4/store"
"go.opentelemetry.io/otel"
"go.opentelemetry.io/otel/trace"
Expand Down
2 changes: 1 addition & 1 deletion pkg/storage/utils/decomposedfs/upload.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import (
"time"

"github.com/google/uuid"
tusd "github.com/tus/tusd/pkg/handler"
tusd "github.com/tus/tusd/v2/pkg/handler"

provider "github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1"
"github.com/cs3org/reva/v2/pkg/appctx"
Expand Down
2 changes: 1 addition & 1 deletion pkg/storage/utils/decomposedfs/upload/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
"strconv"
"time"

tusd "github.com/tus/tusd/pkg/handler"
tusd "github.com/tus/tusd/v2/pkg/handler"

userpb "github.com/cs3org/go-cs3apis/cs3/identity/user/v1beta1"
provider "github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1"
Expand Down
2 changes: 1 addition & 1 deletion pkg/storage/utils/decomposedfs/upload/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ import (
"github.com/google/uuid"
"github.com/pkg/errors"
"github.com/rogpeppe/go-internal/lockedfile"
tusd "github.com/tus/tusd/pkg/handler"
tusd "github.com/tus/tusd/v2/pkg/handler"
)

var _idRegexp = regexp.MustCompile(".*/([^/]+).info")
Expand Down
4 changes: 2 additions & 2 deletions pkg/storage/utils/decomposedfs/upload/upload.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ import (
"github.com/cs3org/reva/v2/pkg/storage/utils/decomposedfs/node"
"github.com/golang-jwt/jwt"
"github.com/pkg/errors"
tusd "github.com/tus/tusd/pkg/handler"
tusd "github.com/tus/tusd/v2/pkg/handler"
"go.opentelemetry.io/otel"
"go.opentelemetry.io/otel/trace"
)
Expand Down Expand Up @@ -94,7 +94,7 @@ func (session *OcisSession) GetInfo(_ context.Context) (tusd.FileInfo, error) {
}

// GetReader returns an io.Reader for the upload
func (session *OcisSession) GetReader(ctx context.Context) (io.Reader, error) {
func (session *OcisSession) GetReader(ctx context.Context) (io.ReadCloser, error) {
_, span := tracer.Start(session.Context(ctx), "GetReader")
defer span.End()
return os.Open(session.binPath())
Expand Down
4 changes: 2 additions & 2 deletions pkg/storage/utils/localfs/upload.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import (
"github.com/cs3org/reva/v2/pkg/utils"
"github.com/google/uuid"
"github.com/pkg/errors"
tusd "github.com/tus/tusd/pkg/handler"
tusd "github.com/tus/tusd/v2/pkg/handler"
)

var defaultFilePerm = os.FileMode(0664)
Expand Down Expand Up @@ -296,7 +296,7 @@ func (upload *fileUpload) GetInfo(ctx context.Context) (tusd.FileInfo, error) {
}

// GetReader returns an io.Reader for the upload
func (upload *fileUpload) GetReader(ctx context.Context) (io.Reader, error) {
func (upload *fileUpload) GetReader(ctx context.Context) (io.ReadCloser, error) {
return os.Open(upload.binPath)
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/storage/utils/middleware/middleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (
"io"
"net/url"

tusd "github.com/tus/tusd/pkg/handler"
tusd "github.com/tus/tusd/v2/pkg/handler"

provider "github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1"
"github.com/cs3org/reva/v2/pkg/storage"
Expand Down

0 comments on commit c6a5c69

Please sign in to comment.