Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to disable TUS on OC layer #791

Merged
merged 1 commit into from
Jun 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions internal/http/services/owncloud/ocdav/ocdav.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ type Config struct {
WebdavNamespace string `mapstructure:"webdav_namespace"`
ChunkFolder string `mapstructure:"chunk_folder"`
GatewaySvc string `mapstructure:"gatewaysvc"`
DisableTus bool `mapstructure:"disable_tus"`
}

type svc struct {
Expand Down
13 changes: 7 additions & 6 deletions internal/http/services/owncloud/ocdav/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,16 @@ func (s *svc) handleOptions(w http.ResponseWriter, r *http.Request, ns string) {
allow += " MOVE, UNLOCK, PROPFIND, MKCOL, REPORT, SEARCH,"
allow += " PUT" // TODO(jfd): only for files ... but we cannot create the full path without a user ... which we only have when credentials are sent

w.Header().Add("Access-Control-Allow-Headers", "Tus-Resumable")
w.Header().Add("Access-Control-Expose-Headers", "Tus-Resumable, Tus-Version, Tus-Extension")

w.Header().Set("Content-Type", "application/xml")
w.Header().Set("Allow", allow)
w.Header().Set("DAV", "1, 2")
w.Header().Set("MS-Author-Via", "DAV")
w.Header().Set("Tus-Resumable", "1.0.0") // TODO(jfd): only for dirs?
w.Header().Set("Tus-Version", "1.0.0")
w.Header().Set("Tus-Extension", "creation,creation-with-upload")
if !s.c.DisableTus {
w.Header().Add("Access-Control-Allow-Headers", "Tus-Resumable")
w.Header().Add("Access-Control-Expose-Headers", "Tus-Resumable, Tus-Version, Tus-Extension")
w.Header().Set("Tus-Resumable", "1.0.0") // TODO(jfd): only for dirs?
w.Header().Set("Tus-Version", "1.0.0")
w.Header().Set("Tus-Extension", "creation,creation-with-upload")
}
w.WriteHeader(http.StatusOK)
}
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 @@ -169,7 +169,7 @@ func (s *svc) handlePropfind(w http.ResponseWriter, r *http.Request, ns string)
w.Header().Set("DAV", "1, 3, extended-mkcol")
w.Header().Set("Content-Type", "application/xml; charset=utf-8")
// let clients know this collection supports tus.io POST requests to start uploads
if info.Type == provider.ResourceType_RESOURCE_TYPE_CONTAINER {
if info.Type == provider.ResourceType_RESOURCE_TYPE_CONTAINER && !s.c.DisableTus {
w.Header().Add("Access-Control-Expose-Headers", "Tus-Resumable, Tus-Version, Tus-Extension")
w.Header().Set("Tus-Resumable", "1.0.0")
w.Header().Set("Tus-Version", "1.0.0")
Expand Down
6 changes: 5 additions & 1 deletion internal/http/services/owncloud/ocdav/webdav.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,11 @@ func (h *WebDavHandler) Handler(s *svc) http.Handler {
case http.MethodPut:
s.handlePut(w, r, h.namespace)
case http.MethodPost:
s.handleTusPost(w, r, h.namespace)
if !s.c.DisableTus {
s.handleTusPost(w, r, h.namespace)
} else {
w.WriteHeader(http.StatusNotFound)
}
case http.MethodOptions:
s.handleOptions(w, r, h.namespace)
case http.MethodHead:
Expand Down
1 change: 1 addition & 0 deletions internal/http/services/owncloud/ocs/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,5 @@ type Config struct {
Config data.ConfigData `mapstructure:"config"`
Capabilities data.CapabilitiesData `mapstructure:"capabilities"`
GatewaySvc string `mapstructure:"gatewaysvc"`
DisableTus bool `mapstructure:"disable_tus"`
}
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ func (h *Handler) Init(c *config.Config) {
// h.c.Capabilities.Files.Undelete is boolean
// h.c.Capabilities.Files.Versioning is boolean

if h.c.Capabilities.Files.TusSupport == nil {
if h.c.Capabilities.Files.TusSupport == nil && !c.DisableTus {
// these are global capabilities
// TODO: infer from various TUS handlers from all known storages
h.c.Capabilities.Files.TusSupport = &data.CapabilitiesFilesTusSupport{
Expand Down