ocdav

package
v2.19.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 29, 2024 License: Apache-2.0 Imports: 57 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MethodPropfind  = "PROPFIND"
	MethodLock      = "LOCK"
	MethodUnlock    = "UNLOCK"
	MethodProppatch = "PROPPATCH"
	MethodMkcol     = "MKCOL"
	MethodMove      = "MOVE"
	MethodCopy      = "COPY"
	MethodReport    = "REPORT"
)

Common Webdav methods.

Unless otherwise noted, these are defined in RFC 4918 section 9.

View Source
const (
	// PerfMarkerResponseTime corresponds to the interval at which a performance marker is sent back to the TPC client
	PerfMarkerResponseTime float64 = 5
)

Variables

Propagator ensures the importer module uses the same trace propagation strategy.

Functions

func ContextWithTokenStatInfo added in v2.19.0

func ContextWithTokenStatInfo(ctx context.Context, info *cs3storage.ResourceInfo) context.Context

ContextWithTokenStatInfo adds the token stat info to the context

func FindName added in v2.19.0

func FindName(ctx context.Context, client gatewayv1beta1.GatewayAPIClient, name string, parentid *provider.ResourceId) (string, *rpc.Status, error)

FindName returns the next filename available when the current

func New

func New(m map[string]interface{}, log *zerolog.Logger) (global.Service, error)

New returns a new ocdav service

func NewWith added in v2.2.0

NewWith returns a new ocdav service

func TokenStatInfoFromContext added in v2.19.0

func TokenStatInfoFromContext(ctx context.Context) (*cs3storage.ResourceInfo, bool)

TokenStatInfoFromContext returns the token stat info from the context

func ValidateName added in v2.13.0

func ValidateName(name string, validators []Validator) error

ValidateName will validate a file or folder name, returning an error when it is not accepted

Types

type AvatarsHandler

type AvatarsHandler struct {
}

AvatarsHandler handles avatar requests

func (*AvatarsHandler) Handler

func (h *AvatarsHandler) Handler(s *svc) http.Handler

Handler handles requests

type Condition

type Condition struct {
	Not   bool
	Token string
	ETag  string
}

Condition can match a WebDAV resource, based on a token or ETag. Exactly one of Token and ETag should be non-empty.

type DavHandler

type DavHandler struct {
	AvatarsHandler      *AvatarsHandler
	FilesHandler        *WebDavHandler
	FilesHomeHandler    *WebDavHandler
	MetaHandler         *MetaHandler
	TrashbinHandler     *TrashbinHandler
	SpacesHandler       *SpacesHandler
	PublicFolderHandler *WebDavHandler
	PublicFileHandler   *PublicFileHandler
	SharesHandler       *WebDavHandler
	OCMSharesHandler    *WebDavHandler
}

DavHandler routes to the different sub handlers

func (*DavHandler) Handler

func (h *DavHandler) Handler(s *svc) http.Handler

Handler handles requests

type LockDetails

type LockDetails struct {
	// Root is the root resource name being locked. For a zero-depth lock, the
	// root is the only resource being locked.
	Root *provider.Reference
	// Duration is the lock timeout. A negative duration means infinite.
	Duration time.Duration
	// OwnerXML is the verbatim <owner> XML given in a LOCK HTTP request.
	//
	// TODO: does the "verbatim" nature play well with XML namespaces?
	// Does the OwnerXML field need to have more structure? See
	// https://codereview.appspot.com/175140043/#msg2
	OwnerXML string
	UserID   *userpb.UserId
	// ZeroDepth is whether the lock has zero depth. If it does not have zero
	// depth, it has infinite depth.
	ZeroDepth bool
	// OwnerName is the name of the lock owner
	OwnerName string
	// Locktime is the time the lock was created
	Locktime time.Time
}

LockDetails are a lock's metadata.

type LockSystem

type LockSystem interface {
	// Confirm confirms that the caller can claim all of the locks specified by
	// the given conditions, and that holding the union of all of those locks
	// gives exclusive access to all of the named resources. Up to two resources
	// can be named. Empty names are ignored.
	//
	// Exactly one of release and err will be non-nil. If release is non-nil,
	// all of the requested locks are held until release is called. Calling
	// release does not unlock the lock, in the WebDAV UNLOCK sense, but once
	// Confirm has confirmed that a lock claim is valid, that lock cannot be
	// Confirmed again until it has been released.
	//
	// If Confirm returns ErrConfirmationFailed then the Handler will continue
	// to try any other set of locks presented (a WebDAV HTTP request can
	// present more than one set of locks). If it returns any other non-nil
	// error, the Handler will write a "500 Internal Server Error" HTTP status.
	Confirm(ctx context.Context, now time.Time, name0, name1 string, conditions ...Condition) (release func(), err error)

	// Create creates a lock with the given depth, duration, owner and root
	// (name). The depth will either be negative (meaning infinite) or zero.
	//
	// If Create returns ErrLocked then the Handler will write a "423 Locked"
	// HTTP status. If it returns any other non-nil error, the Handler will
	// write a "500 Internal Server Error" HTTP status.
	//
	// See http://www.webdav.org/specs/rfc4918.html#rfc.section.9.10.6 for
	// when to use each error.
	//
	// The token returned identifies the created lock. It should be an absolute
	// URI as defined by RFC 3986, Section 4.3. In particular, it should not
	// contain whitespace.
	Create(ctx context.Context, now time.Time, details LockDetails) (token string, err error)

	// Refresh refreshes the lock with the given token.
	//
	// If Refresh returns ErrLocked then the Handler will write a "423 Locked"
	// HTTP Status. If Refresh returns ErrNoSuchLock then the Handler will write
	// a "412 Precondition Failed" HTTP Status. If it returns any other non-nil
	// error, the Handler will write a "500 Internal Server Error" HTTP status.
	//
	// See http://www.webdav.org/specs/rfc4918.html#rfc.section.9.10.6 for
	// when to use each error.
	Refresh(ctx context.Context, now time.Time, token string, duration time.Duration) (LockDetails, error)

	// Unlock unlocks the lock with the given token.
	//
	// If Unlock returns ErrForbidden then the Handler will write a "403
	// Forbidden" HTTP Status. If Unlock returns ErrLocked then the Handler
	// will write a "423 Locked" HTTP status. If Unlock returns ErrNoSuchLock
	// then the Handler will write a "409 Conflict" HTTP Status. If it returns
	// any other non-nil error, the Handler will write a "500 Internal Server
	// Error" HTTP status.
	//
	// See http://www.webdav.org/specs/rfc4918.html#rfc.section.9.11.1 for
	// when to use each error.
	Unlock(ctx context.Context, now time.Time, ref *provider.Reference, token string) error
}

LockSystem manages access to a collection of named resources. The elements in a lock name are separated by slash ('/', U+002F) characters, regardless of host operating system convention.

func NewCS3LS

NewCS3LS returns a new CS3 based LockSystem.

type MetaHandler

type MetaHandler struct {
	VersionsHandler *VersionsHandler
}

MetaHandler handles meta requests

func (*MetaHandler) Handler

func (h *MetaHandler) Handler(s *svc) http.Handler

Handler handles requests

type PerfResponse added in v2.3.0

type PerfResponse struct {
	Timestamp time.Time
	Bytes     uint64
	Index     int
	Count     int
}

PerfResponse provides a single chunk of permormance marker response

type Proppatch

type Proppatch struct {
	// Remove specifies whether this patch removes properties. If it does not
	// remove them, it sets them.
	Remove bool
	// Props contains the properties to be set or removed.
	Props []prop.PropertyXML
}

Proppatch describes a property update instruction as defined in RFC 4918. See http://www.webdav.org/specs/rfc4918.html#METHOD_PROPPATCH

type PublicFileHandler

type PublicFileHandler struct {
	// contains filtered or unexported fields
}

PublicFileHandler handles requests on a shared file. it needs to be wrapped in a collection

func (*PublicFileHandler) Handler

func (h *PublicFileHandler) Handler(s *svc) http.Handler

Handler handles requests

type SpacesHandler

type SpacesHandler struct {
	// contains filtered or unexported fields
}

SpacesHandler handles trashbin requests

func (*SpacesHandler) Handler

func (h *SpacesHandler) Handler(s *svc, trashbinHandler *TrashbinHandler) http.Handler

Handler handles requests

type TrashbinHandler

type TrashbinHandler struct {
	// contains filtered or unexported fields
}

TrashbinHandler handles trashbin requests

func (*TrashbinHandler) Handler

func (h *TrashbinHandler) Handler(s *svc) http.Handler

Handler handles requests

type Validator added in v2.13.0

type Validator func(string) error

Validator validates strings

func ValidatorsFromConfig added in v2.13.0

func ValidatorsFromConfig(c *config.Config) []Validator

ValidatorsFromConfig returns the configured Validators

type VersionsHandler

type VersionsHandler struct {
}

VersionsHandler handles version requests

func (*VersionsHandler) Handler

func (h *VersionsHandler) Handler(s *svc, rid *provider.ResourceId) http.Handler

Handler handles requests versions can be listed with a PROPFIND to /remote.php/dav/meta/<fileid>/v a version is identified by a timestamp, eg. /remote.php/dav/meta/<fileid>/v/1561410426

type WebDavHandler

type WebDavHandler struct {
	// contains filtered or unexported fields
}

WebDavHandler implements a dav endpoint

func (*WebDavHandler) Handler

func (h *WebDavHandler) Handler(s *svc) http.Handler

Handler handles requests

type WriteCounter added in v2.3.0

type WriteCounter struct {
	Total    uint64
	PrevTime time.Time
	// contains filtered or unexported fields
}

WriteCounter counts the number of bytes transferred and reports back to the TPC client about the progress of the transfer through the performance marker response stream.

func (*WriteCounter) SendPerfMarker added in v2.3.0

func (wc *WriteCounter) SendPerfMarker(size uint64)

SendPerfMarker flushes a single chunk (performance marker) as part of the chunked transfer encoding scheme.

func (*WriteCounter) Write added in v2.3.0

func (wc *WriteCounter) Write(p []byte) (int, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL