metadata

package
v2.20.0 Latest Latest
Warning

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

Go to latest
Published: Jun 19, 2024 License: Apache-2.0 Imports: 26 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CS3

type CS3 struct {
	SpaceRoot *provider.ResourceId
	// contains filtered or unexported fields
}

CS3 represents a metadata storage with a cs3 storage backend

func NewCS3 added in v2.19.2

func NewCS3(gwAddr, providerAddr string) (s *CS3)

NewCS3 returns a new CS3 instance. Use an authenticated context and be sure to define SpaceRoot manually.

func (*CS3) Backend

func (cs3 *CS3) Backend() string

Backend returns the backend name of the storage

func (cs3 *CS3) CreateSymlink(ctx context.Context, oldname, newname string) error

CreateSymlink creates a symlink

func (*CS3) Delete

func (cs3 *CS3) Delete(ctx context.Context, path string) error

Delete deletes a path

func (*CS3) Download added in v2.16.0

func (cs3 *CS3) Download(ctx context.Context, req DownloadRequest) (*DownloadResponse, error)

Download reads a file from the metadata storage

func (*CS3) Init

func (cs3 *CS3) Init(ctx context.Context, spaceid string) (err error)

Init creates the metadata space

func (*CS3) ListDir added in v2.8.0

func (cs3 *CS3) ListDir(ctx context.Context, path string) ([]*provider.ResourceInfo, error)

ListDir returns a list of ResourceInfos for the entries in a given directory

func (*CS3) MakeDirIfNotExist

func (cs3 *CS3) MakeDirIfNotExist(ctx context.Context, folder string) error

MakeDirIfNotExist will create a root node in the metadata storage. Requires an authenticated context.

func (*CS3) ReadDir

func (cs3 *CS3) ReadDir(ctx context.Context, path string) ([]string, error)

ReadDir returns the entries in a given directory

func (cs3 *CS3) ResolveSymlink(ctx context.Context, name string) (string, error)

ResolveSymlink resolves a symlink

func (*CS3) SimpleDownload

func (cs3 *CS3) SimpleDownload(ctx context.Context, downloadpath string) (content []byte, err error)

SimpleDownload reads a file from the metadata storage

func (*CS3) SimpleUpload

func (cs3 *CS3) SimpleUpload(ctx context.Context, uploadpath string, content []byte) error

SimpleUpload uploads a file to the metadata storage

func (*CS3) Stat added in v2.8.0

func (cs3 *CS3) Stat(ctx context.Context, path string) (*provider.ResourceInfo, error)

Stat returns the metadata for the given path

func (*CS3) Upload added in v2.8.0

func (cs3 *CS3) Upload(ctx context.Context, req UploadRequest) (*UploadResponse, error)

Upload uploads a file to the metadata storage

type Disk

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

Disk represents a disk metadata storage

func (*Disk) Backend

func (disk *Disk) Backend() string

Backend returns the backend name of the storage

func (disk *Disk) CreateSymlink(_ context.Context, oldname, newname string) error

CreateSymlink creates a symlink

func (*Disk) Delete

func (disk *Disk) Delete(_ context.Context, path string) error

Delete deletes a path

func (*Disk) Download added in v2.16.0

func (disk *Disk) Download(_ context.Context, req DownloadRequest) (*DownloadResponse, error)

Download reads a file from disk

func (*Disk) Init

func (disk *Disk) Init(_ context.Context, _ string) (err error)

Init creates the metadata space

func (*Disk) ListDir added in v2.8.0

func (disk *Disk) ListDir(ctx context.Context, path string) ([]*provider.ResourceInfo, error)

ListDir returns a list of ResourceInfos for the entries in a given directory

func (*Disk) MakeDirIfNotExist

func (disk *Disk) MakeDirIfNotExist(_ context.Context, path string) error

MakeDirIfNotExist will create a root node in the metadata storage. Requires an authenticated context.

func (*Disk) ReadDir

func (disk *Disk) ReadDir(_ context.Context, p string) ([]string, error)

ReadDir returns the resource infos in a given directory

func (disk *Disk) ResolveSymlink(_ context.Context, path string) (string, error)

ResolveSymlink resolves a symlink

func (*Disk) SimpleDownload

func (disk *Disk) SimpleDownload(ctx context.Context, downloadpath string) ([]byte, error)

SimpleDownload reads a file from disk

func (*Disk) SimpleUpload

func (disk *Disk) SimpleUpload(ctx context.Context, uploadpath string, content []byte) error

SimpleUpload stores a file on disk

func (*Disk) Stat added in v2.8.0

func (disk *Disk) Stat(ctx context.Context, path string) (*provider.ResourceInfo, error)

Stat returns the metadata for the given path

func (*Disk) Upload added in v2.8.0

func (disk *Disk) Upload(_ context.Context, req UploadRequest) (*UploadResponse, error)

Upload stores a file on disk

type DownloadRequest added in v2.16.0

type DownloadRequest struct {
	Path        string
	IfNoneMatch []string
}

DownloadRequest represents a download request and its options

type DownloadResponse added in v2.16.0

type DownloadResponse struct {
	Content []byte

	Etag  string
	Mtime time.Time
}

DownloadResponse represents a download response and its options

type Storage

type Storage interface {
	Backend() string

	Init(ctx context.Context, name string) (err error)
	Upload(ctx context.Context, req UploadRequest) (*UploadResponse, error)
	Download(ctx context.Context, req DownloadRequest) (*DownloadResponse, error)
	SimpleUpload(ctx context.Context, uploadpath string, content []byte) error
	SimpleDownload(ctx context.Context, path string) ([]byte, error)
	Delete(ctx context.Context, path string) error
	Stat(ctx context.Context, path string) (*provider.ResourceInfo, error)

	ReadDir(ctx context.Context, path string) ([]string, error)
	ListDir(ctx context.Context, path string) ([]*provider.ResourceInfo, error)

	CreateSymlink(ctx context.Context, oldname, newname string) error
	ResolveSymlink(ctx context.Context, name string) (string, error)

	MakeDirIfNotExist(ctx context.Context, name string) error
}

Storage is the interface to maintain metadata in a storage

func NewCS3Storage

func NewCS3Storage(gwAddr, providerAddr, serviceUserID, serviceUserIDP, machineAuthAPIKey string) (s Storage, err error)

NewCS3Storage returns a new cs3 storage instance. Context passed to methods is irrelevant as the service user will be used. Be sure to call Init before using the storage.

func NewDiskStorage

func NewDiskStorage(dataDir string) (s Storage, err error)

NewDiskStorage returns a new disk storage instance

type UploadRequest added in v2.8.0

type UploadRequest struct {
	Path    string
	Content []byte

	IfMatchEtag       string
	IfNoneMatch       []string
	IfUnmodifiedSince time.Time
	MTime             time.Time
}

UploadRequest represents an upload request and its options

type UploadResponse added in v2.16.0

type UploadResponse struct {
	Etag   string
	FileID string // only for cs3 storage
}

UploadResponse represents a upload response

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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