dav

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2026 License: MIT Imports: 22 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package dav serves the drive over WebDAV: a webdav.FileSystem built per request for one user over the drive store. Every operation goes through the store, which authorizes it.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Mtime added in v0.4.3

func Mtime(header string) (string, error)

Mtime parses an X-OC-Mtime header (Unix seconds, as ownCloud clients and rclone send it) into the drive's form. "" means absent.

func Serve

func Serve(w http.ResponseWriter, r *http.Request, prefix string, f *FS, locks *Locks)

Serve answers one WebDAV request under prefix with f, the requesting user's file system. Callers authenticate first; f carries the user.

func WorkspaceNames added in v0.4.3

func WorkspaceNames(list []drive.Workspace) map[string]string

WorkspaceNames maps each workspace's display name to its ID; duplicate names get " (2)", " (3)" in workspace ID order, after the user's own My files, which always keeps its name. The MCP tools use it so agents see the WebDAV tree.

Types

type FS

type FS struct {

	// IfMatch is set when the request's If-Match was checked: a write then publishes against
	// exactly the revision opened, instead of retrying as last writer wins.
	IfMatch bool
	// Match is the If-Match value that matched ("*": any file): the file opened for writing
	// must still carry it, or the write is a conflict.
	Match string
	// CreateOnly is set by If-None-Match: *: opening an existing file for writing is a conflict.
	CreateOnly bool
	// Err is the last drive error, so the caller can answer with its real status: x/net
	// reports every failed PUT as 405.
	Err error
	// contains filtered or unexported fields
}

FS is one request's view of the drive. Paths are /<workspace>/<folder>/.../<name>.

func New

func New(store *drive.Store, user, blobs string, key []byte, maxFile int64, mtime string) *FS

New builds one request's view. mtime is the request's X-OC-Mtime from Mtime.

func (*FS) Body

func (f *FS) Body(r io.ReadCloser) io.ReadCloser

Body wraps a request body so a failed read (a dropped connection) is remembered: x/net closes the file even when copying the body failed, and a truncated upload must not be published.

func (*FS) Mkdir

func (f *FS) Mkdir(ctx context.Context, name string, _ os.FileMode) error

func (*FS) OpenFile

func (f *FS) OpenFile(ctx context.Context, name string, flag int, _ os.FileMode) (webdav.File, error)

func (*FS) RemoveAll

func (f *FS) RemoveAll(ctx context.Context, name string) error

RemoveAll moves a file or folder to the trash; WebDAV never purges.

func (*FS) Rename

func (f *FS) Rename(ctx context.Context, oldName, newName string) error

Rename moves a file anywhere the store allows, and a folder within its workspace.

func (*FS) Stat

func (f *FS) Stat(ctx context.Context, name string) (os.FileInfo, error)

type Locks

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

Locks is the server's one lock table. Each request sees it through a view that names locks by workspace ID, not by the user's display names, and signs tokens to the user.

func NewLocks

func NewLocks() *Locks

Jump to

Keyboard shortcuts

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