decomposedfs

package
v2.13.3 Latest Latest
Warning

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

Go to latest
Published: May 17, 2023 License: Apache-2.0 Imports: 51 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsEditor added in v2.13.0

func IsEditor(rp provider.ResourcePermissions) bool

IsEditor returns true if the given resource permissions evaluate the user as "editor"

func IsManager added in v2.13.0

func IsManager(rp provider.ResourcePermissions) bool

IsManager returns true if the given resource permissions evaluate the user as "manager"

func IsViewer added in v2.13.0

func IsViewer(rp provider.ResourcePermissions) bool

IsViewer returns true if the given resource permissions evaluate the user as "viewer"

func New

New returns an implementation of the storage.FS interface that talks to a local filesystem.

func NewDefault

func NewDefault(m map[string]interface{}, bs tree.Blobstore, es events.Stream) (storage.FS, error)

NewDefault returns an instance with default components

func ReadSpaceAndNodeFromIndexLink(link string) (string, string, error)

ReadSpaceAndNodeFromIndexLink reads a symlink and parses space and node id if the link has the correct format, eg: ../../spaces/4c/510ada-c86b-4815-8820-42cdf82c3d51/nodes/4c/51/0a/da/-c86b-4815-8820-42cdf82c3d51 ../../spaces/4c/510ada-c86b-4815-8820-42cdf82c3d51/nodes/4c/51/0a/da/-c86b-4815-8820-42cdf82c3d51.T.2022-02-24T12:35:18.196484592Z

Types

type CS3PermissionsClient

type CS3PermissionsClient interface {
	CheckPermission(ctx context.Context, in *cs3permissions.CheckPermissionRequest, opts ...grpc.CallOption) (*cs3permissions.CheckPermissionResponse, error)
}

CS3PermissionsClient defines an interface for checking permissions against the CS3 permissions service

type Decomposedfs

type Decomposedfs struct {
	UserCache *ttlcache.Cache
	// contains filtered or unexported fields
}

Decomposedfs provides the base for decomposed filesystem implementations

func (*Decomposedfs) AddGrant

func (fs *Decomposedfs) AddGrant(ctx context.Context, ref *provider.Reference, g *provider.Grant) (err error)

AddGrant adds a grant to a resource

func (*Decomposedfs) AsConcatableUpload

func (fs *Decomposedfs) AsConcatableUpload(up tusd.Upload) tusd.ConcatableUpload

AsConcatableUpload returns a ConcatableUpload To implement the concatenation extension as specified in https://tus.io/protocols/resumable-upload.html#concatenation the storage needs to implement AsConcatableUpload

func (*Decomposedfs) AsLengthDeclarableUpload

func (fs *Decomposedfs) AsLengthDeclarableUpload(up tusd.Upload) tusd.LengthDeclarableUpload

AsLengthDeclarableUpload returns a LengthDeclarableUpload To implement the creation-defer-length extension as specified in https://tus.io/protocols/resumable-upload.html#creation the storage needs to implement AsLengthDeclarableUpload

func (*Decomposedfs) AsTerminatableUpload

func (fs *Decomposedfs) AsTerminatableUpload(up tusd.Upload) tusd.TerminatableUpload

AsTerminatableUpload returns a TerminatableUpload To implement the termination extension as specified in https://tus.io/protocols/resumable-upload.html#termination the storage needs to implement AsTerminatableUpload

func (*Decomposedfs) CreateDir

func (fs *Decomposedfs) CreateDir(ctx context.Context, ref *provider.Reference) (err error)

CreateDir creates the specified directory

func (*Decomposedfs) CreateHome

func (fs *Decomposedfs) CreateHome(ctx context.Context) (err error)

CreateHome creates a new home node for the given user

func (*Decomposedfs) CreateReference

func (fs *Decomposedfs) CreateReference(ctx context.Context, p string, targetURI *url.URL) (err error)

CreateReference creates a reference as a node folder with the target stored in extended attributes There is no difference between the /Shares folder and normal nodes because the storage is not supposed to be accessible without the storage provider. In effect everything is a shadow namespace. To mimic the eos and owncloud driver we only allow references as children of the "/Shares" folder FIXME: This comment should explain briefly what a reference is in this context.

func (*Decomposedfs) CreateStorageSpace

CreateStorageSpace creates a storage space

func (*Decomposedfs) Delete

func (fs *Decomposedfs) Delete(ctx context.Context, ref *provider.Reference) (err error)

Delete deletes the specified resource

func (*Decomposedfs) DeleteRevision added in v2.13.0

func (fs *Decomposedfs) DeleteRevision(ctx context.Context, ref *provider.Reference, revisionKey string) error

DeleteRevision deletes the specified revision of the resource

func (*Decomposedfs) DeleteStorageSpace

func (fs *Decomposedfs) DeleteStorageSpace(ctx context.Context, req *provider.DeleteStorageSpaceRequest) error

DeleteStorageSpace deletes a storage space

func (*Decomposedfs) DenyGrant

func (fs *Decomposedfs) DenyGrant(ctx context.Context, ref *provider.Reference, grantee *provider.Grantee) error

DenyGrant denies access to a resource.

func (*Decomposedfs) Download

func (fs *Decomposedfs) Download(ctx context.Context, ref *provider.Reference) (io.ReadCloser, error)

Download returns a reader to the specified resource

func (*Decomposedfs) DownloadRevision

func (fs *Decomposedfs) DownloadRevision(ctx context.Context, ref *provider.Reference, revisionKey string) (io.ReadCloser, error)

DownloadRevision returns a reader for the specified revision FIXME the CS3 api should explicitly allow initiating revision and trash download, a related issue is https://github.com/cs3org/reva/issues/1813

func (*Decomposedfs) EmptyRecycle

func (fs *Decomposedfs) EmptyRecycle(ctx context.Context, ref *provider.Reference) error

EmptyRecycle empties the trash

func (*Decomposedfs) GetHome

func (fs *Decomposedfs) GetHome(ctx context.Context) (string, error)

GetHome is called to look up the home path for a user It is NOT supposed to return the internal path but the external path

func (*Decomposedfs) GetLock

func (fs *Decomposedfs) GetLock(ctx context.Context, ref *provider.Reference) (*provider.Lock, error)

GetLock returns an existing lock on the given reference

func (*Decomposedfs) GetMD

func (fs *Decomposedfs) GetMD(ctx context.Context, ref *provider.Reference, mdKeys []string, fieldMask []string) (ri *provider.ResourceInfo, err error)

GetMD returns the metadata for the specified resource

func (*Decomposedfs) GetPathByID

func (fs *Decomposedfs) GetPathByID(ctx context.Context, id *provider.ResourceId) (string, error)

GetPathByID returns the fn pointed by the file id, without the internal namespace

func (*Decomposedfs) GetQuota

func (fs *Decomposedfs) GetQuota(ctx context.Context, ref *provider.Reference) (total uint64, inUse uint64, remaining uint64, err error)

GetQuota returns the quota available TODO Document in the cs3 should we return quota or free space?

func (*Decomposedfs) GetUpload

func (fs *Decomposedfs) GetUpload(ctx context.Context, id string) (tusd.Upload, error)

GetUpload returns the Upload for the given upload id

func (*Decomposedfs) InitiateUpload

func (fs *Decomposedfs) InitiateUpload(ctx context.Context, ref *provider.Reference, uploadLength int64, metadata map[string]string) (map[string]string, error)

InitiateUpload returns upload ids corresponding to different protocols it supports TODO read optional content for small files in this request TODO InitiateUpload (and Upload) needs a way to receive the expected checksum. Maybe in metadata as 'checksum' => 'sha1 aeosvp45w5xaeoe' = lowercase, space separated?

func (*Decomposedfs) ListFolder

func (fs *Decomposedfs) ListFolder(ctx context.Context, ref *provider.Reference, mdKeys []string, fieldMask []string) ([]*provider.ResourceInfo, error)

ListFolder returns a list of resources in the specified folder

func (*Decomposedfs) ListGrants

func (fs *Decomposedfs) ListGrants(ctx context.Context, ref *provider.Reference) (grants []*provider.Grant, err error)

ListGrants lists the grants on the specified resource

func (*Decomposedfs) ListRecycle

func (fs *Decomposedfs) ListRecycle(ctx context.Context, ref *provider.Reference, key, relativePath string) ([]*provider.RecycleItem, error)

ListRecycle returns the list of available recycle items ref -> the space (= resourceid), key -> deleted node id, relativePath = relative to key

func (*Decomposedfs) ListRevisions

func (fs *Decomposedfs) ListRevisions(ctx context.Context, ref *provider.Reference) (revisions []*provider.FileVersion, err error)

ListRevisions lists the revisions of the given resource

func (*Decomposedfs) ListStorageSpaces

func (fs *Decomposedfs) ListStorageSpaces(ctx context.Context, filter []*provider.ListStorageSpacesRequest_Filter, unrestricted bool) ([]*provider.StorageSpace, error)

ListStorageSpaces returns a list of StorageSpaces. The list can be filtered by space type or space id. Spaces are persisted with symlinks in /spaces/<type>/<spaceid> pointing to ../../nodes/<nodeid>, the root node of the space The spaceid is a concatenation of storageid + "!" + nodeid

func (*Decomposedfs) ListUploads added in v2.7.3

func (fs *Decomposedfs) ListUploads() ([]tusd.FileInfo, error)

ListUploads returns a list of all incomplete uploads

func (*Decomposedfs) Move

func (fs *Decomposedfs) Move(ctx context.Context, oldRef, newRef *provider.Reference) (err error)

Move moves a resource from one reference to another

func (*Decomposedfs) MustCheckNodePermissions added in v2.7.3

func (fs *Decomposedfs) MustCheckNodePermissions(ctx context.Context, unrestricted bool) bool

MustCheckNodePermissions checks if permission checks are needed to be performed when user requests spaces

func (*Decomposedfs) NewUpload

func (fs *Decomposedfs) NewUpload(ctx context.Context, info tusd.FileInfo) (tusd.Upload, error)

NewUpload returns a new tus Upload instance

func (*Decomposedfs) Postprocessing added in v2.13.0

func (fs *Decomposedfs) Postprocessing(ch <-chan events.Event)

Postprocessing starts the postprocessing result collector

func (*Decomposedfs) PurgeExpiredUploads added in v2.7.3

func (fs *Decomposedfs) PurgeExpiredUploads(purgedChan chan<- tusd.FileInfo) error

PurgeExpiredUploads scans the fs for expired downloads and removes any leftovers

func (*Decomposedfs) PurgeRecycleItem

func (fs *Decomposedfs) PurgeRecycleItem(ctx context.Context, ref *provider.Reference, key, relativePath string) error

PurgeRecycleItem purges the specified item, all its children and all their revisions

func (*Decomposedfs) RefreshLock

func (fs *Decomposedfs) RefreshLock(ctx context.Context, ref *provider.Reference, lock *provider.Lock, existingLockID string) error

RefreshLock refreshes an existing lock on the given reference

func (*Decomposedfs) RemoveGrant

func (fs *Decomposedfs) RemoveGrant(ctx context.Context, ref *provider.Reference, g *provider.Grant) (err error)

RemoveGrant removes a grant from resource

func (*Decomposedfs) RestoreRecycleItem

func (fs *Decomposedfs) RestoreRecycleItem(ctx context.Context, ref *provider.Reference, key, relativePath string, restoreRef *provider.Reference) error

RestoreRecycleItem restores the specified item

func (*Decomposedfs) RestoreRevision

func (fs *Decomposedfs) RestoreRevision(ctx context.Context, ref *provider.Reference, revisionKey string) (returnErr error)

RestoreRevision restores the specified revision of the resource

func (*Decomposedfs) SetArbitraryMetadata

func (fs *Decomposedfs) SetArbitraryMetadata(ctx context.Context, ref *provider.Reference, md *provider.ArbitraryMetadata) (err error)

SetArbitraryMetadata sets the metadata on a resource

func (*Decomposedfs) SetLock

func (fs *Decomposedfs) SetLock(ctx context.Context, ref *provider.Reference, lock *provider.Lock) error

SetLock puts a lock on the given reference

func (*Decomposedfs) Shutdown

func (fs *Decomposedfs) Shutdown(ctx context.Context) error

Shutdown shuts down the storage

func (*Decomposedfs) TouchFile

func (fs *Decomposedfs) TouchFile(ctx context.Context, ref *provider.Reference, markprocessing bool) error

TouchFile as defined in the storage.FS interface

func (*Decomposedfs) Unlock

func (fs *Decomposedfs) Unlock(ctx context.Context, ref *provider.Reference, lock *provider.Lock) error

Unlock removes an existing lock from the given reference

func (*Decomposedfs) UnsetArbitraryMetadata

func (fs *Decomposedfs) UnsetArbitraryMetadata(ctx context.Context, ref *provider.Reference, keys []string) (err error)

UnsetArbitraryMetadata unsets the metadata on the given resource

func (*Decomposedfs) UpdateGrant

func (fs *Decomposedfs) UpdateGrant(ctx context.Context, ref *provider.Reference, g *provider.Grant) error

UpdateGrant updates a grant on a resource TODO remove AddGrant or UpdateGrant grant from CS3 api, redundant? tracked in https://github.com/cs3org/cs3apis/issues/92

func (*Decomposedfs) UpdateStorageSpace

UpdateStorageSpace updates a storage space

func (*Decomposedfs) Upload

Upload uploads data to the given resource TODO Upload (and InitiateUpload) needs a way to receive the expected checksum. Maybe in metadata as 'checksum' => 'sha1 aeosvp45w5xaeoe' = lowercase, space separated?

func (*Decomposedfs) UseIn

func (fs *Decomposedfs) UseIn(composer *tusd.StoreComposer)

UseIn tells the tus upload middleware which extensions it supports.

func (*Decomposedfs) UserIDToUserAndGroups added in v2.13.0

func (fs *Decomposedfs) UserIDToUserAndGroups(ctx context.Context, userid *userv1beta1.UserId) (*userv1beta1.User, error)

UserIDToUserAndGroups converts a user ID to a user with groups

type Permissions added in v2.13.0

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

Permissions manages permissions

func NewPermissions added in v2.13.0

func NewPermissions(item PermissionsChecker, space CS3PermissionsClient) Permissions

NewPermissions returns a new Permissions instance

func (Permissions) AssemblePermissions added in v2.13.0

func (p Permissions) AssemblePermissions(ctx context.Context, n *node.Node) (provider.ResourcePermissions, error)

AssemblePermissions is used to assemble file permissions

func (Permissions) CreateSpace added in v2.13.0

func (p Permissions) CreateSpace(ctx context.Context, spaceid string) bool

CreateSpace returns true when the user is allowed to create the space

func (Permissions) DeleteAllHomeSpaces added in v2.13.0

func (p Permissions) DeleteAllHomeSpaces(ctx context.Context) bool

DeleteAllHomeSpaces returns true when the user is allowed to delete all home spaces

func (Permissions) DeleteAllSpaces added in v2.13.0

func (p Permissions) DeleteAllSpaces(ctx context.Context) bool

DeleteAllSpaces returns true when the user is allowed to delete all spaces

func (Permissions) ListAllSpaces added in v2.13.0

func (p Permissions) ListAllSpaces(ctx context.Context) bool

ListAllSpaces returns true when the user is allowed to list all spaces

func (Permissions) ListSpacesOfUser added in v2.13.0

func (p Permissions) ListSpacesOfUser(ctx context.Context, userid *userv1beta1.UserId) bool

ListSpacesOfUser returns true when the user is allowed to list the spaces of the given user

func (Permissions) ManageSpaceProperties added in v2.13.0

func (p Permissions) ManageSpaceProperties(ctx context.Context, spaceid string) bool

ManageSpaceProperties returns true when the user is allowed to change space properties (name/subtitle)

func (Permissions) SetSpaceQuota added in v2.13.0

func (p Permissions) SetSpaceQuota(ctx context.Context, spaceid string, spaceType string) bool

SetSpaceQuota returns true when the user is allowed to change the spaces quota

func (Permissions) SpaceAbility added in v2.13.0

func (p Permissions) SpaceAbility(ctx context.Context, spaceid string) bool

SpaceAbility returns true when the user is allowed to enable/disable the space

type PermissionsChecker

type PermissionsChecker interface {
	AssemblePermissions(ctx context.Context, n *node.Node) (ap provider.ResourcePermissions, err error)
}

PermissionsChecker defines an interface for checking permissions on a Node

type Tree

type Tree interface {
	Setup() error

	GetMD(ctx context.Context, node *node.Node) (os.FileInfo, error)
	ListFolder(ctx context.Context, node *node.Node) ([]*node.Node, error)
	// CreateHome(owner *userpb.UserId) (n *node.Node, err error)
	CreateDir(ctx context.Context, node *node.Node) (err error)
	TouchFile(ctx context.Context, node *node.Node, markprocessing bool) error
	// CreateReference(ctx context.Context, node *node.Node, targetURI *url.URL) error
	Move(ctx context.Context, oldNode *node.Node, newNode *node.Node) (err error)
	Delete(ctx context.Context, node *node.Node) (err error)
	RestoreRecycleItemFunc(ctx context.Context, spaceid, key, trashPath string, target *node.Node) (*node.Node, *node.Node, func() error, error)
	PurgeRecycleItemFunc(ctx context.Context, spaceid, key, purgePath string) (*node.Node, func() error, error)

	WriteBlob(node *node.Node, source string) error
	ReadBlob(node *node.Node) (io.ReadCloser, error)
	DeleteBlob(node *node.Node) error

	Propagate(ctx context.Context, node *node.Node, sizeDiff int64) (err error)
}

Tree is used to manage a tree hierarchy

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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