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 ¶
- func Mtime(header string) (string, error)
- func Serve(w http.ResponseWriter, r *http.Request, prefix string, f *FS, locks *Locks)
- func WorkspaceNames(list []drive.Workspace) map[string]string
- type FS
- func (f *FS) Body(r io.ReadCloser) io.ReadCloser
- func (f *FS) Mkdir(ctx context.Context, name string, _ os.FileMode) error
- func (f *FS) OpenFile(ctx context.Context, name string, flag int, _ os.FileMode) (webdav.File, error)
- func (f *FS) RemoveAll(ctx context.Context, name string) error
- func (f *FS) Rename(ctx context.Context, oldName, newName string) error
- func (f *FS) Stat(ctx context.Context, name string) (os.FileInfo, error)
- type Locks
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Mtime ¶ added in v0.4.3
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 ¶
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
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 (*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.