drive

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: 49 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

Index

Constants

View Source
const (

	// AgentIdleLimit is how long an agent token may go unused before it is revoked.
	AgentIdleLimit = 90 * 24 * time.Hour
	// AgentTokenPrefix marks an agent token; device tokens are DevicePrefix.
	AgentTokenPrefix = "kya_"
)

App passwords let a user's own WebDAV client sign in with HTTP Basic. Each is 160 random bits shown once, stored as SHA-256 (no slow hash: the secret is not guessable), and valid only while its account is active. AI agent tokens share the table with an MCP scope: Bearer credentials for /mcp only, never WebDAV, revoked after AgentIdleLimit unused.

View Source
const (
	ScopeDAV      = "dav"
	ScopeMCPRead  = "mcp:read"
	ScopeMCPWrite = "mcp:write"
)

Scopes: a WebDAV password, or an agent token that reads, or reads and writes.

View Source
const (
	TicketLife = 15 * time.Minute

	// PeerFolderName is the folder KyPost's files go into, made on first use at the root of My files.
	PeerFolderName = "Mail attachments"
)

KyPost saves files into a user's My files through upload tickets (docs/KYPOST.md). What a peer context may do is access.go's; this file holds the switch, the folder and the tickets.

View Source
const (
	ThumbnailSize    = 256
	ThumbnailMaxFile = 64 << 20
)

Thumbnails are PNGs of raster images inside ThumbnailSize square. A decompression bomb is refused from its header: the decoder's memory is bounded before any pixel buffer exists, and one image decodes at a time.

View Source
const (
	ViewLife = 24 * time.Hour

	// ViewMaxBytes is the save-attachment limit: KyPost's 25 MiB inbound cap.
	ViewMaxBytes = int64(25 << 20)
	// ViewKeyPrefix names a viewing copy's Euro-Office document key; ParseDocumentKey refuses it.
	ViewKeyPrefix = "view-"
)

Viewing copies (docs/KYPOST.md "Viewing copies"): one mail attachment KyPost sends for one person to read in Euro-Office's view mode. A copy is not a file: no folder, share, link, search, change row, WebDAV, MCP or sync ever sees it. It counts against My files' quota from the moment its ticket is issued, and it is gone at ViewLife.

View Source
const (
	DevicePrefix = "kyd_"
)

Device credentials are a client's own bearer tokens. A computer links through the browser: it receives a one-time code on its loopback listener and redeems it with its PKCE verifier. A phone scans a one-time code the signed-in user shows as a QR code. Codes and tokens are 256 random bits, stored as SHA-256 only. A device may enrol a P-256 signing key when it links, and only then: DeviceUser hands it to the caller to check the request's signature.

View Source
const OperatorActor = "system:operator-cli"

OperatorActor records handovers run from the server CLI.

View Source
const PickLife = 24 * time.Hour

PickLife is how long KyPost may fetch a file the user chose in the picker's copy mode.

Variables

View Source
var (
	// ErrPeerOff is a peer write refused because the user's KyPost switch is off.
	ErrPeerOff = errors.New("kypost switch off")
	// ErrPeerGone is a peer write refused because the pairing it came under has ended.
	ErrPeerGone = errors.New("kypost no longer paired")
)
View Source
var (
	ErrDenied   = errors.New("drive access denied")
	ErrConflict = errors.New("revision conflict")
	ErrQuota    = errors.New("workspace quota exceeded")
	ErrInvalid  = errors.New("invalid drive input")
	// ErrTooLarge is a body over the upload limit; it is also ErrQuota.
	ErrTooLarge = fmt.Errorf("%w: upload limit", ErrQuota)
)
View Source
var ErrGone = errors.New("change cursor expired")

ErrGone is a change cursor below rows that were pruned; the client must re-enumerate.

View Source
var ErrNoThumbnail = errors.New("no thumbnail for this file")
View Source
var ErrNotFound = errors.New("drive item not found")

ErrNotFound means no live item has that name; distinct from ErrDenied, which hides existence.

View Source
var ErrPassword = errors.New("link password required or wrong")

A guest link lets someone without an account view and download one file or folder, or, in upload-only mode, drop files into one folder without seeing it. It always expires. It works only while its creator could still create it, so a link dies with its creator's access. Every unusable link answers ErrNotFound; a missing or wrong password is ErrPassword.

View Source
var ErrPeerGuestOff = errors.New("kypost guest links off")

ErrPeerGuestOff is a KyPost guest link refused because the user's guest switch is off.

View Source
var ErrTicketLimit = errors.New("too many live upload tickets")

ErrTicketLimit is a user already holding ticketsPerUser live tickets.

View Source
var ErrUnsupported = errors.New("content does not match its type")

ErrUnsupported is content that is not what its name says.

View Source
var ErrWrongKey = errors.New("drive: deployment key does not match this database")

ErrWrongKey means the deployment key differs from the one this drive was first opened with.

Functions

func BlobPath

func BlobPath(root, id string) (string, error)

func DocumentKey

func DocumentKey(file string, revision, epoch int64) string

DocumentKey names one editor document. Epoch 0 keeps the original "<file>-<revision>" form; a cross-workspace move starts a new epoch so sessions after it never share a key with older ones.

func FileType added in v0.6.1

func FileType(name string) string

FileType is the search type of a file named name, by its last extension ignoring case, or "".

func IsAgentScope added in v0.4.3

func IsAgentScope(scope string) bool

func LinkID

func LinkID(token string) string

LinkID names a guest link for rate limiting and audit without revealing its token.

func Mtime added in v0.4.3

func Mtime(s string) (string, error)

Mtime normalizes an RFC 3339 client mtime to UTC. "" stays "" (absent). Times before 1970 or more than a day ahead are ErrInvalid.

func OpenBlob

func OpenBlob(path string, key []byte, sealed bool, size int64) (io.ReadSeekCloser, error)

OpenBlob opens a stored blob of size plaintext bytes for reading. A sealed blob must have exactly the size its format gives; its last chunk is authenticated before OpenBlob returns and every other chunk before any of its bytes are read. A KYB2 blob opens only under the file name (blob ID) it was written for.

func OpenThumb added in v0.4.3

func OpenThumb(root string, key []byte, blob string) (io.ReadSeekCloser, error)

OpenThumb streams a cache entry (thumbnail or document text), authenticating each chunk as it is read; a missing one is fs.ErrNotExist.

func ParseDeviceKey added in v0.6.1

func ParseDeviceKey(der []byte) (*ecdsa.PublicKey, error)

ParseDeviceKey accepts a P-256 public key as SPKI DER, the only signing key a device enrols.

func ParseDocumentKey

func ParseDocumentKey(key string) (file string, revision, epoch int64, err error)

func Rank

func Rank(role string) int

func ReadThumb

func ReadThumb(root string, key []byte, blob string) ([]byte, error)

ReadThumb opens a cached thumbnail; a missing one is fs.ErrNotExist.

func RemoveBlobs

func RemoveBlobs(root string, ids []string) error

RemoveBlobs deletes blobs whose last reference was purged. A missing file is already gone.

func SealedSize

func SealedSize(plain int64) int64

SealedSize is the on-disk size of a KYB2 blob holding plain bytes.

func StoredSizeOK added in v0.5.0

func StoredSizeOK(sealed bool, plain, disk int64) bool

StoredSizeOK reports whether disk bytes can hold plain bytes stored as sealed says.

func SyncDirectory

func SyncDirectory(path string) error

func Thumbnail

func Thumbnail(ctx context.Context, r io.ReadSeeker, size int64) ([]byte, error)

Thumbnail returns a PNG thumbnail of the raster image in r, which holds size bytes.

func ValidName

func ValidName(name string) bool

func ValidType added in v0.6.1

func ValidType(t string) bool

ValidType reports whether t is a search type filter ("" is no filter).

func ViewKind added in v0.6.1

func ViewKind(name string) (ext, kind string)

ViewKind is name's lowercase extension and Euro-Office document type, or "" for a type a viewing copy may not have.

func WithDevice added in v0.4.3

func WithDevice(ctx context.Context) context.Context

WithDevice marks ctx as acting through a device token, which syncs files and nothing more: every method that creates or changes access, or mints a session or credential, refuses it (admin() included), so revoking a device leaves nothing of it behind. devices_access_test.go classifies every exported Store method.

func WithLogin added in v0.5.0

func WithLogin(ctx context.Context, l Login) context.Context

WithLogin binds the editor sessions opened through ctx to l, so a back-channel logout of that sign-in revokes them even after its browser session expired and was removed.

func WithPeer added in v0.6.1

func WithPeer(ctx context.Context, p Peer) context.Context

WithPeer marks ctx as KyPost acting, under p, for the user it names in each call.

func WithServiceAccess

func WithServiceAccess(ctx context.Context, a ServiceAccess) context.Context

func WriteThumb

func WriteThumb(root string, key []byte, blob string, thumb []byte) error

WriteThumb seals a thumbnail under key as root/<blob>: named by blob, never by digest, so the cache cannot confirm what a file holds. It is bound as a cache entry, so it never opens as a blob.

Types

type AppPassword

type AppPassword struct {
	ID       string `json:"id"`
	Name     string `json:"name"`
	Created  string `json:"created"`
	LastUsed int64  `json:"last_used"`
	Scope    string `json:"scope"`
	// Workspace limits an agent token to Folder in it ("" = the workspace root); empty means
	// everything its user can reach.
	Workspace string `json:"workspace,omitempty"`
	Folder    string `json:"folder,omitempty"`
	// RevokeAfter is when an unused agent token is revoked, Unix seconds; 0 for WebDAV.
	RevokeAfter int64 `json:"revoke_after,omitempty"`
}

type Change added in v0.4.3

type Change struct {
	Kind    string  `json:"kind"`
	ID      string  `json:"id"`
	Removed bool    `json:"removed"`
	File    *File   `json:"file,omitempty"`
	Folder  *Folder `json:"folder,omitempty"`
}

Change is an item's current state: live with File or Folder set, or Removed (trashed, purged or now in another workspace).

type Colleague

type Colleague struct {
	ID   string `json:"id"`
	Name string `json:"name"`
}

type ContentMatcher added in v0.4.3

type ContentMatcher interface {
	Match(ctx context.Context, q string, files []File) (map[string]float64, error)
}

ContentMatcher scores the files among files whose content matches q, keyed by file ID. files are exactly the live files the user can read in the searched scope; the matcher must not look beyond them.

type DeletedWorkspace added in v0.6.1

type DeletedWorkspace struct {
	ID        string `json:"id"`
	Name      string `json:"name"`
	DeletedAt string `json:"deleted_at"`
	DeletedBy string `json:"deleted_by"`
	Used      int64  `json:"used"`
	Items     int64  `json:"items"`
}

DeletedWorkspace is a shared workspace in its recovery period, for administrators: its size and item count, never file names.

type Device added in v0.4.3

type Device struct {
	ID       string `json:"id"`
	Name     string `json:"name"`
	Platform string `json:"platform"`
	Created  string `json:"created"`
	LastUsed int64  `json:"last_used"`
}

type EditorSession

type EditorSession struct {
	ID, FileID, User, Key string
	Revision              int64
	Expires               int64
}

type ErrDeviceRevoked added in v0.4.3

type ErrDeviceRevoked struct{ Wipe bool }

ErrDeviceRevoked answers a revoked token for 30 days, telling the device whether to wipe.

func (ErrDeviceRevoked) Error added in v0.4.3

func (ErrDeviceRevoked) Error() string

func (ErrDeviceRevoked) Is added in v0.4.3

func (ErrDeviceRevoked) Is(target error) bool

Is lets a revoked token count as denied wherever its wipe flag is not needed.

type Event

type Event struct {
	ID       string `json:"id"`
	User     string `json:"user"`
	Action   string `json:"action"`
	Resource string `json:"resource"`
	Created  string `json:"created"`
}

type File

type File struct {
	ID        string `json:"id"`
	Workspace string `json:"workspace"`
	Parent    string `json:"parent"`
	Name      string `json:"name"`
	Revision  int64  `json:"revision"`
	Trashed   bool   `json:"trashed"`
	Size      int64  `json:"size"`
	Digest    string `json:"digest"`
	Blob      string `json:"-"`
	Sealed    bool   `json:"-"`
	Modified  string `json:"modified"` // when the current version was created
	Mtime     string `json:"mtime"`    // the client's modification time, else Modified
}

type Folder

type Folder struct {
	ID        string `json:"id"`
	Workspace string `json:"workspace"`
	Parent    string `json:"parent"`
	Name      string `json:"name"`
	Trashed   bool   `json:"trashed"`
}

type Grant

type Grant struct {
	GroupID string `json:"group_id"`
	Name    string `json:"name"`
	Role    string `json:"role"`
}

type GuestItem

type GuestItem struct {
	Kind string `json:"kind"`
	ID   string `json:"id"`
	Name string `json:"name"`
	Size int64  `json:"size"`
}

GuestItem is a file or folder as a guest sees it: never its workspace or anything above the link.

type GuestLink struct {
	ID          string `json:"id"`
	Expires     int64  `json:"expires"`
	Created     string `json:"created"`
	CreatedBy   string `json:"created_by"`
	UploadOnly  bool   `json:"upload_only"`
	HasPassword bool   `json:"has_password"`
}

type GuestListing

type GuestListing struct {
	Name       string      `json:"name"` // the shared item's name
	Kind       string      `json:"kind"`
	UploadOnly bool        `json:"upload_only"`
	Path       []GuestItem `json:"path"` // folders from the link's folder down to the one listed
	Items      []GuestItem `json:"items"`
}

type Hit

type Hit struct {
	Kind      string   `json:"kind"`
	ID        string   `json:"id"`
	Workspace string   `json:"workspace"`
	Parent    string   `json:"parent"`
	Name      string   `json:"name"`
	Path      string   `json:"path"`
	Match     []string `json:"match"`
	// Shared is set on an item reached only through Shared with me; Path then starts at the
	// shared item, never above it.
	Shared *SharedFrom `json:"shared,omitempty"`
	// contains filtered or unexported fields
}

Hit is a live file or folder whose name or content matched. Path joins its ancestor folder names with "/". Match lists "name" and/or "content".

type Item

type Item struct {
	Folder *Folder
	File   *File
}

Item is a live folder or file; exactly one is set.

type Leaver

type Leaver struct {
	Workspace string `json:"workspace"`
	Name      string `json:"name"`
	Status    string `json:"status"`
	Size      int64  `json:"size"`
	Items     int    `json:"items"`
}

Leaver is a personal workspace whose owner can no longer use it. It carries counts, never names.

type Link struct {
	ID        string `json:"id"`
	Role      string `json:"role"`
	Expires   int64  `json:"expires"` // unix seconds, 0 for never
	Created   string `json:"created"`
	CreatedBy string `json:"created_by"`
	Opened    int    `json:"opened"`
}

type Location

type Location struct{ Workspace, Parent, Name string }

type Login added in v0.5.0

type Login struct {
	TokenHash, SSOSID string
	At                time.Time
}

Login is the browser sign-in a request acts through: its session token hash, the identity provider's sid ("" for a local sign-in) and when its credentials were verified.

type Peer added in v0.6.1

type Peer struct {
	SwitchDefault bool
	Live          func() bool
	Pairing       string
}

Peer is the pairing a peer context acts under. SwitchDefault is the user's switch when they never chose (on for a KyIdentity pairing, off for an environment one); Live reports whether that pairing still stands. peerSwitch checks both in the transaction of the write it allows, so an unpair or a switch turned off while bytes stream publishes nothing. Pairing fingerprints the pairing (never its secret); a ticket keeps the one it was issued under and works only while it is current.

type Person

type Person struct {
	ID       string `json:"id"`
	Name     string `json:"name"`
	Username string `json:"username"`
}

Person is an active account a user can share with.

type ServiceAccess

type ServiceAccess struct {
	Workspace string
	Rank      int
	Token     string // the service token's ID
}

type Share

type Share struct {
	ID            string `json:"id"`
	ResourceKind  string `json:"resource_kind"`
	ResourceID    string `json:"resource_id"`
	PrincipalKind string `json:"principal_kind"`
	PrincipalID   string `json:"principal_id"`
	Name          string `json:"name"`
	Role          string `json:"role"`
}

Share is one grant on a folder or file to a person or a group.

type SharedFrom added in v0.6.1

type SharedFrom struct {
	From string `json:"from"`
	Role string `json:"role"`
}

SharedFrom names where a shared hit comes from, as Shared with me shows it: the workspace's name, or a personal workspace owner's display name, and the user's highest role there.

type SharedItem

type SharedItem struct {
	Kind          string `json:"kind"`
	ID            string `json:"id"`
	Workspace     string `json:"workspace"`
	WorkspaceName string `json:"workspace_name"`
	Parent        string `json:"parent"`
	Name          string `json:"name"`
	Role          string `json:"role"`
}

SharedItem is a folder or file someone shared with the user beyond their own workspace access.

type Store

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

func New

func New(ctx context.Context, db *sql.DB, key []byte) (*Store, error)

New opens the drive store. key is the deployment key; names are sealed under keys derived from it.

func (*Store) AddFolder

func (s *Store) AddFolder(ctx context.Context, user, workspace, parent, name string) (Folder, error)

func (*Store) AgentTokenUser added in v0.4.3

func (s *Store) AgentTokenUser(ctx context.Context, token string, at time.Time) (string, AppPassword, error)

AgentTokenUser returns the user and record of an active user's agent token. WebDAV passwords never match. A token unused for AgentIdleLimit before at is deleted and refused like a wrong one, whether or not the sweep has run.

func (*Store) AppPasswordUser

func (s *Store) AppPasswordUser(ctx context.Context, username, secret string) (string, error)

AppPasswordUser returns the ID of the active user named username (any case) that owns secret. Agent tokens never match.

func (*Store) AppPasswords

func (s *Store) AppPasswords(ctx context.Context, user string) ([]AppPassword, error)

func (*Store) AppendUpload

func (s *Store) AppendUpload(ctx context.Context, staging string, key []byte, user, id string, start, length int64, r io.Reader) (UploadSession, error)

AppendUpload seals exactly length bytes of r as the segment starting at start, which must be the session's received count. Concurrent appends at one offset: one wins, the rest ErrConflict.

func (*Store) ApplyRetention

func (s *Store) ApplyRetention(ctx context.Context, at time.Time, trashDays int) ([]string, error)

ApplyRetention purges what workspace policies have expired as of at. trashDays (0 = off) empties the trash of every workspace, personal ones included, whose own trash_days is 0. Each item commits on its own and is re-checked against the policy in force inside that transaction, so one document still open in an editor does not hold back the rest. Selection pages by cursor, so permanently skipped items cannot starve later ones.

func (s *Store) ApproveLink(ctx context.Context, user, name, platform, challenge, redirect string) (string, error)

ApproveLink records the signed-in user's approval and returns the one-time code for the client's loopback redirect.

func (*Store) ApprovePhone added in v0.6.1

func (s *Store) ApprovePhone(ctx context.Context, user string) (string, error)

ApprovePhone returns a one-time code, valid 120 seconds, that the signed-in user shows as a QR code for a phone to scan. A phone code carries no challenge: whoever holds it first links.

func (*Store) Authorize

func (s *Store) Authorize(ctx context.Context, user, workspace string, need int) error

func (*Store) AuthorizeItem

func (s *Store) AuthorizeItem(ctx context.Context, user, workspace, folder, file string, need int) error

AuthorizeItem is authorizeItem for callers outside the package.

func (*Store) AuthorizeSharedManager

func (s *Store) AuthorizeSharedManager(ctx context.Context, user, workspace string) error

func (*Store) CallbackActor

func (s *Store) CallbackActor(ctx context.Context, file string, revision, epoch int64) (string, error)

CallbackActor chooses an authorized participant; ownership does not follow the first opener. Age alone does not refuse a save: the sweep revokes expired sessions once their document closes.

func (*Store) CancelUpload

func (s *Store) CancelUpload(ctx context.Context, staging, user, id string) error

CancelUpload discards the caller's session and its staged bytes.

func (*Store) Changes added in v0.4.3

func (s *Store) Changes(ctx context.Context, user, workspace string, after int64, limit int) (cs []Change, next int64, more bool, err error)

Changes reads up to limit rows after the cursor and returns each item they name once, in order of first appearance, as it is now. next is the cursor for the following call; more reports rows beyond it.

func (*Store) Children

func (s *Store) Children(ctx context.Context, user, workspace, parent string) ([]Folder, []File, error)

Children lists the live folders and files directly under parent, sorted by name.

func (*Store) CloseEditor

func (s *Store) CloseEditor(ctx context.Context, key string) error

CloseEditor records that Euro-Office closed key without changes.

func (*Store) CloseViewCopy added in v0.6.1

func (s *Store) CloseViewCopy(ctx context.Context, user, id string) (blob string, err error)

CloseViewCopy ends user's own copy id and returns its blob for removal ("" when none). An opened copy may still be showing in another tab, so its row stays, revoked, until its Euro-Office drop is delivered (PendingViewDrops); one never opened is deleted.

func (*Store) Colleagues

func (s *Store) Colleagues(ctx context.Context, user string) ([]Colleague, error)

Colleagues lists active accounts that can receive a handover into their My files.

func (*Store) CompleteUpload

func (s *Store) CompleteUpload(ctx context.Context, staging, blobs string, key []byte, user, id string) (File, error)

CompleteUpload publishes a fully received session as a file version and removes it. It ignores cancellation: a proxy that times out on a long re-seal drops the connection, and stopping then would only make every Retry re-seal the whole file again. The size cap bounds the work.

func (*Store) CopyFile

func (s *Store) CopyFile(ctx context.Context, user, id string, to Location) (File, error)

CopyFile publishes the source's current bytes as revision 1 of a new file. The source is read inside the same transaction, so a concurrent purge cannot remove the shared blob.

func (*Store) CreateAgentToken added in v0.4.3

func (s *Store) CreateAgentToken(ctx context.Context, user, name, scope, workspace, folder string) (AppPassword, string, error)

CreateAgentToken returns a new agent token of scope and its secret, which is not stored. With workspace set the token reaches only folder ("" = the workspace root), which must be live and readable by user now; the store still authorizes every later operation as user.

func (*Store) CreateAppPassword

func (s *Store) CreateAppPassword(ctx context.Context, user, name string) (AppPassword, string, error)

CreateAppPassword returns the new password's record and its secret, which is not stored.

func (s *Store) CreateGuestLink(ctx context.Context, user, kind, id string, expires int64, secret string, uploadOnly bool, maxLife time.Duration) (GuestLink, string, error)

CreateGuestLink returns a guest link and its token, which is not stored. maxLife is the administrator's limit; the expiry is mandatory.

func (s *Store) CreateLink(ctx context.Context, user, kind, id, role string, expires int64) (Link, string, error)

CreateLink returns the new link and its token, which is not stored.

func (*Store) CreateServiceToken

func (s *Store) CreateServiceToken(ctx context.Context, user, workspace, name, role, token string) (string, error)

func (*Store) CreateWorkspace

func (s *Store) CreateWorkspace(ctx context.Context, user, name string, quota int64) (Workspace, error)

func (*Store) DeferRevocation

func (s *Store) DeferRevocation(ctx context.Context, id string) error

DeferRevocation backs a failed drop off exponentially, 2s doubling up to an hour, so drops that keep failing queue behind newer ones.

func (*Store) DeleteWorkspace added in v0.5.0

func (s *Store) DeleteWorkspace(ctx context.Context, user, workspace, confirm string) (recoverable bool, err error)

DeleteWorkspace deletes a shared workspace. Admin only; My files is ErrDenied. An unknown or already deleted workspace is nil with no event. recoverable reports which kind ran:

  • Empty (no live or trashed file or folder): it is removed at once with every access to it. An upload in progress refuses it (ErrConflict).
  • Holding items: confirm must be its exact name, else ErrConflict. It is deleted recoverably: every grant and share lapses (they come back on restore), and its links, service tokens, AI agent tokens limited to it and editor sessions are revoked for good. Its files stay until RestoreWorkspace or PurgeDeletedWorkspaces.

func (*Store) DeletedWorkspaces added in v0.6.1

func (s *Store) DeletedWorkspaces(ctx context.Context, user string) ([]DeletedWorkspace, error)

DeletedWorkspaces lists deleted shared workspaces, newest first. Admin only.

func (*Store) DeviceUser added in v0.4.3

func (s *Store) DeviceUser(ctx context.Context, token string, verify func(id string, key *ecdsa.PublicKey) error) (string, error)

DeviceUser returns the active user a live device token belongs to. verify gets the device's ID and enrolled key (nil for an unsigned device) and runs before anything else is revealed or written, so a token without its key learns nothing and keeps nothing alive; its error is returned as is. A token revoked in the last 30 days is ErrDeviceRevoked; anything else unusable is ErrDenied.

func (*Store) Devices added in v0.4.3

func (s *Store) Devices(ctx context.Context, user string) ([]Device, error)

Devices lists the user's live (unrevoked) devices.

func (*Store) EditorDownload

func (s *Store) EditorDownload(ctx context.Context, id string) (File, error)

EditorDownload serves a live session's document at its newest saved revision. The caller has verified that Euro-Office signed the request.

func (*Store) EditorSession

func (s *Store) EditorSession(ctx context.Context, user, id string) (EditorSession, error)

EditorSession opens the file for user. A document a force-save left open at the current revision and epoch is joined, so co-editors always share one key.

func (*Store) EnsurePersonalWorkspace

func (s *Store) EnsurePersonalWorkspace(ctx context.Context, user string) (string, error)

EnsurePersonalWorkspace creates one private workspace per immutable account ID. Ownership is retained when the directory account is removed; another account cannot inherit it.

func (*Store) Events

func (s *Store) Events(ctx context.Context, user string) ([]Event, error)

func (*Store) ExpireAgentTokens added in v0.4.3

func (s *Store) ExpireAgentTokens(ctx context.Context, at time.Time) (int, error)

ExpireAgentTokens revokes every agent token unused for AgentIdleLimit before at and returns how many. AgentTokenUser refuses an idle token on its own; this removes the ones nobody presents.

func (*Store) ExpireTickets added in v0.6.1

func (s *Store) ExpireTickets(ctx context.Context) error

ExpireTickets deletes expired tickets and picks. Their sessions expire with them (ExpireUploads).

func (*Store) ExpireUploads

func (s *Store) ExpireUploads(ctx context.Context, staging string) (int, error)

ExpireUploads removes expired sessions, then staging directories with no session that are an hour old (crash residue; the hour keeps a session that is starting up safe). Staging is not user data.

func (*Store) ExpireViewCopies added in v0.6.1

func (s *Store) ExpireViewCopies(ctx context.Context) ([]string, error)

ExpireViewCopies ends copies past ViewLife and returns the blobs to remove. An opened copy Euro-Office may still be showing is revoked, not deleted, so PendingViewDrops still drops it; its row goes once the drop is delivered, or editorGrace after expiry if it never is. Unopened copies, unused tickets and delivered drops are deleted.

func (*Store) File

func (s *Store) File(ctx context.Context, user, id string, need int) (File, error)

func (*Store) Files

func (s *Store) Files(ctx context.Context, user, workspace string, trashed bool) ([]File, error)

func (*Store) FolderChildren

func (s *Store) FolderChildren(ctx context.Context, user, id string) (Folder, []Folder, []File, error)

FolderChildren lists a folder the user can read, whatever gives them access to it.

func (*Store) FolderPath added in v0.4.3

func (s *Store) FolderPath(ctx context.Context, user, workspace, id string) ([]string, error)

FolderPath returns the names from the workspace root down to folder id ("" = the root, no names), which user must be able to read. ErrNotFound when the folder or an ancestor is trashed, gone or in another workspace.

func (*Store) FolderTree

func (s *Store) FolderTree(ctx context.Context, user, folder string) (string, []ZipEntry, error)

FolderTree lists a live folder and everything live beneath it, read in one transaction, with paths built only from validated names and rooted at the folder's own name. Access is the workspace's read grant; per-item grants (M3) must recheck each member here.

func (*Store) Folders

func (s *Store) Folders(ctx context.Context, user, workspace string, trashed bool) ([]Folder, error)

func (*Store) Grant

func (s *Store) Grant(ctx context.Context, user, workspace, group, role string) error

func (*Store) Grants

func (s *Store) Grants(ctx context.Context, user, workspace string) ([]Grant, error)

func (*Store) GuestFile

func (s *Store) GuestFile(ctx context.Context, token, secret, id string) (File, error)

GuestFile returns a file a guest link can download, and audits the download.

func (s *Store) GuestLinks(ctx context.Context, user, kind, id string) ([]GuestLink, error)

GuestLinks lists an item's live guest links for those who may share it.

func (*Store) GuestUpload

func (s *Store) GuestUpload(ctx context.Context, token, secret, name string, v Version) (File, error)

GuestUpload publishes a blob into an upload-only link's folder on its creator's authority. A taken name is numbered rather than refused, so a guest cannot learn what the folder holds.

func (*Store) GuestView

func (s *Store) GuestView(ctx context.Context, token, secret, folder string) (GuestListing, error)

GuestView lists what a guest link shows: the file, or a folder at or below the link's folder.

func (*Store) Handover

func (s *Store) Handover(ctx context.Context, user, source string, to Target) (string, error)

Handover moves a leaver's whole personal tree, trash and versions included, into a new folder at the target root and returns that folder. The admin gains no read access.

func (*Store) IndexChanges added in v0.4.3

func (s *Store) IndexChanges(ctx context.Context, after int64, limit int) ([]string, int64, error)

IndexChanges returns the files named by up to limit change rows after seq after, each once, and the last seq read (after itself when there are none).

func (*Store) IndexFile added in v0.4.3

func (s *Store) IndexFile(ctx context.Context, id string) (File, error)

IndexFile returns file id at its current version, trashed or not; ErrNotFound when it is gone.

func (*Store) IndexFiles added in v0.4.3

func (s *Store) IndexFiles(ctx context.Context, afterID string, limit int) ([]File, error)

IndexFiles pages every file at its current version, trashed or not, by ID after afterID.

func (*Store) IssueTicket added in v0.6.1

func (s *Store) IssueTicket(ctx context.Context, user, name string, size, maxSize int64) (string, Ticket, error)

IssueTicket gives KyPost (a peer context) a ticket for one file of exactly size bytes named name, bound to user. The token is 256 random bits, returned once; only its hash is stored.

func (*Store) IssueViewTicket added in v0.6.1

func (s *Store) IssueViewTicket(ctx context.Context, user, name string, size, maxSize int64) (string, ViewCopy, error)

IssueViewTicket (a peer context) reserves a viewing copy of exactly size bytes named name for user and returns its single-use upload ticket, of which only the hash is stored.

func (*Store) Leavers

func (s *Store) Leavers(ctx context.Context, user string) ([]Leaver, error)

Leavers lists non-empty personal workspaces whose owner is missing or not active.

func (s *Store) Links(ctx context.Context, user, kind, id string) ([]Link, error)

Links lists an item's live organisation links for those who may share it; never their tokens.

func (*Store) Lookup

func (s *Store) Lookup(ctx context.Context, user, workspace, parent, name string) (Item, error)

Lookup finds the live folder or file named name under parent by name_hmac, so it never decrypts siblings. A folder wins when both exist.

func (*Store) MarkDropped

func (s *Store) MarkDropped(ctx context.Context, id string) error

func (*Store) MarkViewDropped added in v0.6.1

func (s *Store) MarkViewDropped(ctx context.Context, id string, ok bool) error

MarkViewDropped records a drop, or with ok false backs the next attempt off a minute. ponytail: a flat one-minute retry, not editor sessions' doubling backoff; copies die at ViewLife anyway.

func (*Store) MoveFile

func (s *Store) MoveFile(ctx context.Context, user, id string, expected int64, to Location) (File, error)

MoveFile renames or relocates a file without creating a version. Moving to another workspace needs manager rights on the source, since the file leaves it, plus editor rights and room for every retained version on the target. It revokes every open editor session on the file, since each was authorized for the source workspace.

func (*Store) MoveFolder

func (s *Store) MoveFolder(ctx context.Context, user, id, parent, name string) (Folder, error)

MoveFolder renames or re-parents a live folder within its workspace.

func (s *Store) OpenLink(ctx context.Context, user, token string) (SharedItem, error)

OpenLink gives the user the link's access and returns its item. Every way a link can be unusable (unknown, revoked, expired, trashed item, lapsed owner) is ErrNotFound alike.

func (*Store) OperatorHandover

func (s *Store) OperatorHandover(ctx context.Context, source string, to Target) (string, error)

OperatorHandover is Handover for the server CLI, whose operator already holds the database. It also writes an audit record.

func (*Store) OperatorLeavers

func (s *Store) OperatorLeavers(ctx context.Context) ([]Leaver, error)

OperatorLeavers is Leavers for the server CLI.

func (*Store) PeerFetch added in v0.6.1

func (s *Store) PeerFetch(ctx context.Context, user, id string) (File, error)

PeerFetch (a peer context) is a file KyPost may read for user: picked, live and still readable.

func (*Store) PeerFree added in v0.6.1

func (s *Store) PeerFree(ctx context.Context, user string) (int64, error)

PeerFree is the free quota of the user's My files, or a new one's quota when there is none.

func (s *Store) PeerGuestLink(ctx context.Context, user, id string, expires int64, maxLife time.Duration) (GuestLink, string, error)

PeerGuestLink (a peer context) is KyPost's guest link: view and download, no password, on a file peerLink admits, while the user's guest switch is on (else ErrPeerGuestOff).

func (*Store) PeerGuestSetting added in v0.6.1

func (s *Store) PeerGuestSetting(ctx context.Context, user string) (bool, error)

PeerGuestSetting is "Let KyPost create guest links for people outside the organisation": off unless the user turned it on.

func (*Store) PeerSetting added in v0.6.1

func (s *Store) PeerSetting(ctx context.Context, user string) (enabled, set bool, err error)

PeerSetting is the user's stored choice for "Let KyPost save and share my files"; set is false when they never chose (the caller applies the pairing's default).

func (*Store) PendingRevocations

func (s *Store) PendingRevocations(ctx context.Context) ([]EditorSession, error)

func (*Store) PendingViewDrops added in v0.6.1

func (s *Store) PendingViewDrops(ctx context.Context) ([]ViewCopy, error)

PendingViewDrops are revoked copies Euro-Office may still be showing; the API drops each from Euro-Office and marks it with MarkViewDropped.

func (*Store) People

func (s *Store) People(ctx context.Context, user, q string) ([]Person, error)

People finds active accounts by name or username for an active signed-in user to share with: 2–100 characters, at most 20 results, never the caller, never an email address.

func (*Store) PruneChanges added in v0.4.3

func (s *Store) PruneChanges(ctx context.Context, before time.Time) error

PruneChanges deletes rows created before before, except each workspace's newest, so an idle workspace's cursor stays valid. It raises each workspace's floor to the highest seq it deleted there.

func (*Store) PruneDevices added in v0.4.3

func (s *Store) PruneDevices(ctx context.Context, at time.Time) error

PruneDevices deletes devices revoked 30 days before at or idle for 90, and expired codes.

func (*Store) Publish

func (s *Store) Publish(ctx context.Context, user string, f File, v Version, expected int64) (File, error)

Publish makes a durably stored immutable blob visible. Caller owns that blob until success.

func (*Store) PublishEditor

func (s *Store) PublishEditor(ctx context.Context, user string, f File, v Version, key string, final bool) (bool, error)

PublishEditor serializes a document's saves with other uploads and acknowledges exact retries. The digest of the document's newest save is successful without publishing another blob.

func (*Store) PurgeDeletedWorkspaces added in v0.6.1

func (s *Store) PurgeDeletedWorkspaces(ctx context.Context, at time.Time, days int) ([]string, error)

PurgeDeletedWorkspaces permanently removes workspaces deleted more than days ago (0 = never), as actor system, one transaction each, and returns the blobs left unreferenced for the caller to remove after commit (the orphan sweep catches any it misses). A workspace with a file still open in an editor (an undelivered drop) is skipped until a later run.

func (*Store) PurgeFile

func (s *Store) PurgeFile(ctx context.Context, user, id string) ([]string, error)

func (*Store) PurgeFolder

func (s *Store) PurgeFolder(ctx context.Context, user, id string) ([]string, error)

func (*Store) PurgeVersion

func (s *Store) PurgeVersion(ctx context.Context, user, id string, revision int64) ([]string, error)

func (*Store) Quota

func (s *Store) Quota(ctx context.Context, user, workspace string, quota int64) error

func (*Store) ReconcileSuiteGroups added in v0.6.1

func (s *Store) ReconcileSuiteGroups(ctx context.Context, groups []suitedir.Group) (SuiteReport, error)

ReconcileSuiteGroups moves each suite group's workspace towards the state KyIdentity lists (KyIdentity docs/SUITE-DIRECTORY.md), keyed on the group ID only, as actor system, one transaction per group, so a crash halfway repeats safely and one failing group does not stop the rest. A group absent from groups is left alone. Nothing it made is ever deleted.

func (*Store) RecordPicks added in v0.6.1

func (s *Store) RecordPicks(ctx context.Context, user string, ids []string) error

RecordPicks lets KyPost fetch files for PickLife: the user chose them in the picker's copy mode, in their own session. Each must be a live file the user may share.

func (s *Store) RedeemLink(ctx context.Context, code, verifier string, key []byte) (token, user string, err error)

RedeemLink spends a computer's code once, checks the verifier against its S256 challenge and returns a new device token and its user. Any failure is ErrDenied and burns the code.

func (*Store) RedeemPhone added in v0.6.1

func (s *Store) RedeemPhone(ctx context.Context, code, name, platform string, key []byte) (token, user string, err error)

RedeemPhone spends a phone code from ApprovePhone once and links the named phone. Any failure is ErrDenied and burns the code.

func (*Store) RenameWorkspace added in v0.5.0

func (s *Store) RenameWorkspace(ctx context.Context, user, workspace, name string) error

RenameWorkspace renames a shared workspace. Admin only; My files cannot be renamed.

func (*Store) RestoreVersion

func (s *Store) RestoreVersion(ctx context.Context, user, id string, revision, expected int64) (File, error)

func (*Store) RestoreWorkspace added in v0.6.1

func (s *Store) RestoreWorkspace(ctx context.Context, user, workspace string) error

RestoreWorkspace brings back a deleted shared workspace with its grants and shares. Admin only; a live, personal or unknown workspace is ErrNotFound. Revoked links and tokens stay revoked. Its name was kept reserved (nameFree), so it cannot collide.

func (*Store) RevocationStatus

func (s *Store) RevocationStatus(ctx context.Context) (map[string]int, error)

func (*Store) RevokeAppPassword

func (s *Store) RevokeAppPassword(ctx context.Context, user, id string) error

func (*Store) RevokeDevice added in v0.4.3

func (s *Store) RevokeDevice(ctx context.Context, user, id string, wipe bool) error

RevokeDevice stops one of the user's devices at once; the token keeps answering with wipe for 30 days.

func (s *Store) RevokeLink(ctx context.Context, user, id string) error

RevokeLink ends an organisation or guest link and every access that came through it.

func (*Store) RevokeSSOEditors added in v0.5.0

func (s *Store) RevokeSSOEditors(ctx context.Context, tx *sql.Tx, sid string) error

RevokeSSOEditors revokes, like RevokeUserEditors, the editor sessions opened through the SSO login sid, whether or not its browser session still exists.

func (*Store) RevokeServiceToken

func (s *Store) RevokeServiceToken(ctx context.Context, user, id string) error

func (*Store) RevokeUserCredentials added in v0.6.1

func (s *Store) RevokeUserCredentials(ctx context.Context, tx *sql.Tx, user string) error

RevokeUserCredentials ends, in the caller's transaction, the credentials user issued that outlive a password: WebDAV passwords, agent tokens and pending computer links are deleted, linked computers revoked (no wipe), and service tokens and guest links revoked; revoking a service token also ends the editors opened through it. Organisation links stay: they need a signed-in opener. Nil (no drive store) is a no-op.

func (*Store) RevokeUserEditors

func (s *Store) RevokeUserEditors(ctx context.Context, tx *sql.Tx, user string) error

RevokeUserEditors revokes user's editor sessions in the caller's transaction and starts a new key epoch on their files, so a saved editor configuration cannot rejoin the old document. Nil (no drive store) is a no-op.

func (*Store) RevokeUserEditorsBefore added in v0.5.0

func (s *Store) RevokeUserEditorsBefore(ctx context.Context, tx *sql.Tx, user string, cutoff time.Time) error

RevokeUserEditorsBefore revokes, like RevokeUserEditors, user's editor sessions opened through a sign-in verified before cutoff. Sessions from before login binding count as 0.

func (*Store) SealLegacyBlobs

func (s *Store) SealLegacyBlobs(ctx context.Context, root string, key []byte) (int, error)

SealLegacyBlobs replaces every plaintext blob with a sealed copy under a new ID. Each swap moves all version rows naming the old blob in one transaction and records the old ID in drive_blob_retire; the file is removed after commit. Pending retirements from an interrupted run are finished first, so a rerun is always safe.

func (*Store) Search

func (s *Store) Search(ctx context.Context, user, q string, limit int) ([]Hit, bool, error)

Search matches q case-insensitively against every live name in the workspaces user can read. Names are sealed, so they are decrypted and matched here; SQL never sees them. It returns at most limit hits and whether more matched.

func (*Store) SearchContent added in v0.4.3

func (s *Store) SearchContent(ctx context.Context, user, q, typ string, limit int, m ContentMatcher, shared bool) ([]Hit, bool, error)

SearchContent is Search that also asks m (nil: names only) which readable files' contents match. Name matches come first in Search's order, then content-only matches by score. A type (ValidType) keeps only hits of that type and allows an empty q, which matches every name. shared also searches the items in the user's Shared with me list outside those workspaces (searchShared); every such hit returned is re-checked for read access first.

func (*Store) SearchFolder added in v0.4.3

func (s *Store) SearchFolder(ctx context.Context, user, workspace, folder, q string, limit int) ([]Hit, bool, error)

SearchFolder is Search within the live subtree of folder in workspace ("" = the whole workspace), the folder itself excluded; each Path is relative to folder.

func (*Store) SearchFolderContent added in v0.4.3

func (s *Store) SearchFolderContent(ctx context.Context, user, workspace, folder, q, typ string, limit int, m ContentMatcher) ([]Hit, bool, error)

SearchFolderContent is SearchFolder that also asks m (nil: names only) which files in the subtree match by content, as SearchContent does.

func (*Store) ServiceToken

func (s *Store) ServiceToken(ctx context.Context, token string) (string, ServiceAccess, error)

func (*Store) SetAgentScope added in v0.4.3

func (s *Store) SetAgentScope(ctx context.Context, user, id, scope string) error

SetAgentScope moves the user's own agent token between read and write. A WebDAV password never becomes an agent token, nor the reverse (ErrInvalid).

func (*Store) SetEditorsShare

func (s *Store) SetEditorsShare(ctx context.Context, user, workspace string, on bool) error

SetEditorsShare lets a shared workspace's managers allow its editors to share, up to their role.

func (*Store) SetFolderTrash

func (s *Store) SetFolderTrash(ctx context.Context, user, id string, trash bool) error

SetFolderTrash trashes a folder and everything live beneath it as one batch, or restores exactly that batch. Items trashed earlier stay in the trash. A folder whose parent is still trashed comes back at the workspace root.

func (*Store) SetFolderTrashSince added in v0.6.1

func (s *Store) SetFolderTrashSince(ctx context.Context, user, id string, trash bool, head int64) error

SetFolderTrashSince is SetFolderTrash on the condition that nothing in the folder's live subtree changed after head, the workspace change-log position the caller last saw (a desktop client's cursor). A change row after head naming the folder or a live folder or file beneath it, or a head below the pruned floor, is ErrConflict and changes nothing.

func (*Store) SetPeerGuestSetting added in v0.6.1

func (s *Store) SetPeerGuestSetting(ctx context.Context, user string, enabled bool) error

SetPeerGuestSetting stores the user's own choice. Only the user's sign-in reaches it.

func (*Store) SetPeerSetting added in v0.6.1

func (s *Store) SetPeerSetting(ctx context.Context, user string, enabled bool) error

SetPeerSetting stores the user's own choice. Only the user's sign-in reaches it.

func (*Store) SetRetention

func (s *Store) SetRetention(ctx context.Context, user, workspace string, trashDays, keepVersions int) error

SetRetention configures automatic purging for one workspace; 0 turns a rule off.

func (*Store) SetTrash

func (s *Store) SetTrash(ctx context.Context, user, id string, expected int64, trash bool) error

func (*Store) Share

func (s *Store) Share(ctx context.Context, user, kind, id, principalKind, principalID, role string) (Share, error)

Share grants role on a live folder or file to a person or a group, replacing any role that principal already had there.

func (*Store) SharedWithMe

func (s *Store) SharedWithMe(ctx context.Context, user string) ([]SharedItem, error)

SharedWithMe lists live items shared with the user or their groups at a higher role than the user's own access to the workspace (none, for most), folders first, then by name: a workspace reader with an editor share edits from there. Each item appears once, at its highest shared role.

func (*Store) Shares

func (s *Store) Shares(ctx context.Context, user, kind, id string) ([]Share, error)

Shares lists the people and groups an item is shared with, for those who may share it.

func (*Store) Snapshot added in v0.4.3

func (s *Store) Snapshot(ctx context.Context, user, workspace, afterID string, limit int) (folders []Folder, files []File, head int64, nextID string, err error)

Snapshot pages a workspace's live folders and files by ID after afterID. head is the workspace's change cursor in the same transaction: a client that follows Changes from the first page's head misses nothing written while it paged. nextID is "" on the last page.

func (*Store) StartUpload

func (s *Store) StartUpload(ctx context.Context, user string, u UploadSession, max int64) (UploadSession, error)

StartUpload opens a session for a new file (File empty, Expected 0) or a new version of File at revision Expected. Size must fit max and the workspace's free quota now; Publish checks quota again at completion.

func (*Store) StoreViewCopy added in v0.6.1

func (s *Store) StoreViewCopy(ctx context.Context, root string, key []byte, c ViewCopy, token string, r io.Reader) error

StoreViewCopy (a peer context, under the pairing that issued the ticket) seals exactly c.Size bytes of r into root and spends the ticket. Bytes that do not look like the name's type are ErrUnsupported; a wrong length is ErrInvalid.

func (*Store) SweepOrphans

func (s *Store) SweepOrphans(ctx context.Context, root string, grace time.Duration) (int, error)

SweepOrphans removes staging files left by a crash and blobs no version names. Only files older than grace are touched, so an upload between its rename and its commit is safe; only names WriteBlob creates are considered.

func (*Store) Ticket added in v0.6.1

func (s *Store) Ticket(ctx context.Context, token string) (Ticket, error)

Ticket finds a live ticket by its token's hash; anything else is ErrNotFound.

func (*Store) TicketUpload added in v0.6.1

func (s *Store) TicketUpload(ctx context.Context, staging, blobs string, key []byte, t Ticket, start, length int64, r io.Reader) (received int64, f *File, err error)

TicketUpload (a peer context) stores length bytes of r at start of t's file through the ordinary upload session path, as t's owner in a peer context. The first bytes open the session in the owner's peer folder (made or remade here), under the first free numbered name; the session expires with the ticket. The last bytes publish the file and spend the ticket. f is nil until then.

func (*Store) UnlinkDevice added in v0.4.3

func (s *Store) UnlinkDevice(ctx context.Context, user, token string) error

UnlinkDevice revokes the device that token belongs to, without wipe: the user unlinked it from the computer itself, which keeps its files.

func (*Store) Unshare

func (s *Store) Unshare(ctx context.Context, user, id string) error

Unshare removes a share the user may manage.

func (*Store) UpgradeBlobs added in v0.5.0

func (s *Store) UpgradeBlobs(ctx context.Context, root string, key []byte, rate int64) (int, error)

UpgradeBlobs rewrites every KYB1 blob listed in drive_blob_kyb1 as KYB2 under the same ID, at most rate bytes per second. Each rewrite is staged, synced and decrypted against the version digest before it atomically replaces the blob and drops the queue row, so a run that dies anywhere leaves a readable blob and a rerun is safe. Failed blobs stay queued.

func (*Store) Upload

func (s *Store) Upload(ctx context.Context, user, id string) (UploadSession, error)

Upload returns the caller's own unexpired session, rechecking edit access to its workspace.

func (*Store) Versions

func (s *Store) Versions(ctx context.Context, user, id string) ([]Version, error)

func (*Store) ViewClosed added in v0.6.1

func (s *Store) ViewClosed(ctx context.Context, id string) (string, error)

ViewClosed deletes copy id when Euro-Office reports its document closed: nobody is left to drop.

func (*Store) ViewCopy added in v0.6.1

func (s *Store) ViewCopy(ctx context.Context, user, id string) (ViewCopy, error)

ViewCopy opens user's own stored, unexpired copy id through the sign-in on ctx (WithLogin), binding the copy to it as EditorSession does (only the first sign-in may open it): whatever revokes that sign-in's editors (revokeEditors) revokes the copy too. Anything else is ErrNotFound.

func (*Store) ViewDownload added in v0.6.1

func (s *Store) ViewDownload(ctx context.Context, id string) (ViewCopy, error)

ViewDownload is copy id for Euro-Office, whose signature the caller verified: only a copy opened through a sign-in that has not been revoked.

func (*Store) ViewTicket added in v0.6.1

func (s *Store) ViewTicket(ctx context.Context, token string) (ViewCopy, error)

ViewTicket finds the copy an unspent, unexpired upload ticket names; anything else is ErrNotFound.

func (*Store) Workspaces

func (s *Store) Workspaces(ctx context.Context, user string, administration bool) ([]Workspace, error)

type SuiteReport added in v0.6.1

type SuiteReport struct {
	Created, Renamed, Restored, Archived, MembersChanged int
}

SuiteReport counts what one ReconcileSuiteGroups pass changed.

type Target

type Target struct{ Workspace, User string }

Target is a handover destination: a shared workspace or a colleague's My files.

type Ticket added in v0.6.1

type Ticket struct {
	Pairing string
	ID      string
	Owner   string
	Name    string
	Size    int64
	Expires int64
	Session string
}

Ticket is a live upload ticket. Session is the upload session its first byte opened.

type UploadSession

type UploadSession struct {
	ID        string `json:"id"`
	Workspace string `json:"workspace"`
	Parent    string `json:"parent"`
	Name      string `json:"name"`
	File      string `json:"file"`
	Expected  int64  `json:"revision"`
	Size      int64  `json:"size"`
	Received  int64  `json:"received"`
	Expires   int64  `json:"expires"`
	Mtime     string `json:"mtime"` // applied to the published version
}

type Version

type Version struct {
	FileID   string `json:"file_id"`
	Revision int64  `json:"revision"`
	Blob     string `json:"-"`
	Digest   string `json:"digest"`
	Size     int64  `json:"size"`
	Created  string `json:"created"`
	Mtime    string `json:"mtime"` // optional client modification time, RFC 3339
	Sealed   bool   `json:"-"`
}

func WriteBlob

func WriteBlob(root string, key []byte, r io.Reader, limit int64) (Version, error)

WriteBlob seals r under key, bound to a new blob ID, into a unique staging file and publishes it only after a durable flush. Digest and Size describe the plaintext.

type ViewCopy added in v0.6.1

type ViewCopy struct {
	ID, Owner, Name, Blob, Pairing string
	Size, Expires                  int64
}

ViewCopy is one viewing copy. Blob is empty until its bytes land.

type Workspace

type Workspace struct {
	Kind         string `json:"kind"`
	ID           string `json:"id"`
	Name         string `json:"name"`
	Quota        int64  `json:"quota"`
	Used         int64  `json:"used"`
	Role         string `json:"role"`
	TrashDays    int    `json:"trash_days"`
	KeepVersions int    `json:"keep_versions"`
	EditorsShare bool   `json:"editors_share"`
	Items        int64  `json:"items"` // files and folders, trashed ones included; 0 deletes at once
	Head         int64  `json:"head"`  // newest change seq; unchanged means nothing to fetch
}

type ZipEntry

type ZipEntry struct {
	Path     string
	Blob     string
	Sealed   bool
	Size     int64
	Modified time.Time
}

ZipEntry is one member of a folder download. Directories end in "/" and have no Blob.

Jump to

Keyboard shortcuts

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