Skip to content

Commit

Permalink
Move http utils to pkg
Browse files Browse the repository at this point in the history
  • Loading branch information
ishank011 committed Oct 27, 2020
1 parent 13a882e commit 6f307f7
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 43 deletions.
2 changes: 1 addition & 1 deletion internal/http/services/dataprovider/put.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ func (s *svc) doTusPut(w http.ResponseWriter, r *http.Request) {
"dir": path.Dir(fp),
}

upload := tus.NewUpload(r.Body, length, metadata, "")
upload := tus.NewUpload(fd, length, metadata, "")
defer r.Body.Close()

// create the uploader.
Expand Down
2 changes: 1 addition & 1 deletion internal/http/services/owncloud/ocdav/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ import (

rpc "github.com/cs3org/go-cs3apis/cs3/rpc/v1beta1"
provider "github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1"
"github.com/cs3org/reva/internal/http/utils"
"github.com/cs3org/reva/pkg/appctx"
"github.com/cs3org/reva/pkg/rhttp"
"github.com/cs3org/reva/pkg/utils"
)

func (s *svc) handleGet(w http.ResponseWriter, r *http.Request, ns string) {
Expand Down
2 changes: 1 addition & 1 deletion internal/http/services/owncloud/ocdav/head.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ import (

rpc "github.com/cs3org/go-cs3apis/cs3/rpc/v1beta1"
provider "github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1"
"github.com/cs3org/reva/internal/http/utils"
"github.com/cs3org/reva/pkg/appctx"
"github.com/cs3org/reva/pkg/utils"
)

func (s *svc) handleHead(w http.ResponseWriter, r *http.Request, ns string) {
Expand Down
2 changes: 1 addition & 1 deletion internal/http/services/owncloud/ocdav/propfind.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ import (
rpc "github.com/cs3org/go-cs3apis/cs3/rpc/v1beta1"
provider "github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1"
"github.com/cs3org/reva/internal/http/services/owncloud/ocs/conversions"
"github.com/cs3org/reva/internal/http/utils"
"github.com/cs3org/reva/pkg/appctx"
"github.com/cs3org/reva/pkg/utils"
"github.com/pkg/errors"
)

Expand Down
2 changes: 1 addition & 1 deletion internal/http/services/owncloud/ocdav/put.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ import (
rpc "github.com/cs3org/go-cs3apis/cs3/rpc/v1beta1"
provider "github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1"
typespb "github.com/cs3org/go-cs3apis/cs3/types/v1beta1"
"github.com/cs3org/reva/internal/http/utils"
"github.com/cs3org/reva/pkg/appctx"
"github.com/cs3org/reva/pkg/utils"
)

func isChunked(fn string) (bool, error) {
Expand Down
2 changes: 1 addition & 1 deletion internal/http/services/owncloud/ocdav/trashbin.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ import (
userpb "github.com/cs3org/go-cs3apis/cs3/identity/user/v1beta1"
rpc "github.com/cs3org/go-cs3apis/cs3/rpc/v1beta1"
provider "github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1"
"github.com/cs3org/reva/internal/http/utils"
"github.com/cs3org/reva/pkg/appctx"
"github.com/cs3org/reva/pkg/rgrpc/todo/pool"
"github.com/cs3org/reva/pkg/rhttp/router"
ctxuser "github.com/cs3org/reva/pkg/user"
"github.com/cs3org/reva/pkg/utils"
)

// TrashbinHandler handles trashbin requests
Expand Down
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 @@ -28,9 +28,9 @@ import (
rpc "github.com/cs3org/go-cs3apis/cs3/rpc/v1beta1"
provider "github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1"
typespb "github.com/cs3org/go-cs3apis/cs3/types/v1beta1"
"github.com/cs3org/reva/internal/http/utils"
"github.com/cs3org/reva/pkg/appctx"
"github.com/cs3org/reva/pkg/rhttp"
"github.com/cs3org/reva/pkg/utils"
tusd "github.com/tus/tusd/pkg/handler"
)

Expand Down
36 changes: 0 additions & 36 deletions internal/http/utils/utils.go

This file was deleted.

14 changes: 14 additions & 0 deletions pkg/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ import (
"path/filepath"
"regexp"
"strings"
"time"

types "github.com/cs3org/go-cs3apis/cs3/types/v1beta1"
)

var (
Expand Down Expand Up @@ -92,3 +95,14 @@ func ResolvePath(path string) (string, error) {

return path, nil
}

// TSToUnixNano converts a protobuf Timestamp to uint64
// with nanoseconds resolution.
func TSToUnixNano(ts *types.Timestamp) uint64 {
return uint64(time.Unix(int64(ts.Seconds), int64(ts.Nanos)).UnixNano())
}

// TSToTime converts a protobuf Timestamp to Go's time.Time.
func TSToTime(ts *types.Timestamp) time.Time {
return time.Unix(int64(ts.Seconds), int64(ts.Nanos))
}

0 comments on commit 6f307f7

Please sign in to comment.