fsds

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2020 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultBucketName = "personal"
View Source
var EntryNotFound = syscall.ENOENT // errors.New("Directory entry not found")

EntryNotFound error when a directory is not found

View Source
var RestrictedDirAccessMode = os.ModeDir | 0500 // dr-x------ only allow reading and opening directory for user
View Source
var StandardDirAccessMode = os.ModeDir | 0777 //0700   // drwx------
View Source
var StandardFileAccessMode os.FileMode = 0777 // -rw-------

Functions

This section is empty.

Types

type DirEntry

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

DirEntry implements the DirEntryOps

func NewDirEntry

func NewDirEntry(entry domain.DirEntry) *DirEntry

func NewDirEntryFromFileInfo added in v0.1.3

func NewDirEntryFromFileInfo(info os.FileInfo, path string) *DirEntry

func NewDirEntryWithMode added in v0.0.19

func NewDirEntryWithMode(entry domain.DirEntry, mode os.FileMode) *DirEntry

func (*DirEntry) Ctime

func (d *DirEntry) Ctime() time.Time

Ctime implements the DirEntryAttribute Interface It returns the time the directory was created

func (*DirEntry) Gid added in v0.0.19

func (d *DirEntry) Gid() uint32

func (*DirEntry) IsDir

func (d *DirEntry) IsDir() bool

IsDir implement DirEntryAttribute And returns if the directory is a boolean or not

func (*DirEntry) ModTime

func (d *DirEntry) ModTime() time.Time

ModTime returns the modification time

func (*DirEntry) Mode

func (d *DirEntry) Mode() os.FileMode

Mode implements the DirEntryAttribute Interface Currently if it is a file, returns all access permission 0766 but ideally should restrict the permission if owner is not the same as file

func (*DirEntry) Name

func (d *DirEntry) Name() string

Name implements the DirEntryAttribute Interface

func (*DirEntry) Path

func (d *DirEntry) Path() string

func (*DirEntry) Size

func (d *DirEntry) Size() uint64

Size implements the DirEntryAttribute Interface and return the size of the item

func (*DirEntry) Uid added in v0.0.19

func (d *DirEntry) Uid() uint32

type FSDataSource

type FSDataSource interface {
	// Get a single node, this can be called on either a file or folder entry
	// This is typically used by the OS for lookup of the information about the entry at path
	Get(ctx context.Context, path string) (*DirEntry, error)
	// GetChildren returns child entries in the directory/folder
	GetChildren(ctx context.Context, path string) ([]*DirEntry, error)
	// OpenReader returns a file reader
	Open(ctx context.Context, path string) (FileReadWriterCloser, error)
	// CreateEntry should create a directory or file based on the mode at the path
	CreateEntry(ctx context.Context, path string, mode os.FileMode) (*DirEntry, error)
	// RenameEntry should rename the directory entry from old to new
	RenameEntry(ctx context.Context, oldPath, newPath string) error
	// DeleteEntry should delete the item at the path
	DeleteEntry(ctx context.Context, path string) error
}

FSDataSource is data source of file/directories and their information It is used as a local/remote cache for looking up information about the directories. It should also ensure that the user in the context has permission to data that is being request

type FSDataSourceConfig added in v0.0.19

type FSDataSourceConfig func(config *dataSourceConfig)

func WithFilesDataSources added in v0.0.19

func WithFilesDataSources(service space.Service) FSDataSourceConfig

Configure the default 'Files` data source to be included as a data source

func WithSharedWithMeDataSources added in v0.0.19

func WithSharedWithMeDataSources(service space.Service) FSDataSourceConfig

Configure the default 'Shared With Me` data source to be included as a data source

func WithTLFDataSource added in v0.0.19

func WithTLFDataSource(source *TLFDataSource) FSDataSourceConfig

type FileReadWriterCloser added in v0.0.19

type FileReadWriterCloser interface {
	Read(ctx context.Context, data []byte, offset int64) (int, error)
	Write(ctx context.Context, data []byte, offset int64) (int, error)
	Close(ctx context.Context) error
	Stats(ctx context.Context) (*DirEntry, error)
	Truncate(ctx context.Context, size uint64) error
}

FileReadWriterCloser implements interfaces to read, copy, seek and close.

type SpaceFSDataSource

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

SpaceFSDataSource is an implementation of the FSDataSource It interacts with the Space Service Layer to provide data

func NewSpaceFSDataSource

func NewSpaceFSDataSource(service space.Service, configOptions ...FSDataSourceConfig) *SpaceFSDataSource

func (*SpaceFSDataSource) CreateEntry

func (d *SpaceFSDataSource) CreateEntry(ctx context.Context, path string, mode os.FileMode) (*DirEntry, error)

CreateEntry creates a directory or file based on the mode at the path

func (*SpaceFSDataSource) DeleteEntry added in v0.1.3

func (d *SpaceFSDataSource) DeleteEntry(ctx context.Context, path string) error

func (*SpaceFSDataSource) Get

func (d *SpaceFSDataSource) Get(ctx context.Context, path string) (*DirEntry, error)

Get returns the DirEntry information for item at path

func (*SpaceFSDataSource) GetChildren

func (d *SpaceFSDataSource) GetChildren(ctx context.Context, path string) ([]*DirEntry, error)

GetChildren returns list of entries in a path

func (*SpaceFSDataSource) Open

Open is invoked to read the content of a file

func (*SpaceFSDataSource) RenameEntry added in v0.1.3

func (d *SpaceFSDataSource) RenameEntry(ctx context.Context, oldPath, newPath string) error

type SpaceFilesHandler added in v0.1.3

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

Wrapper around space files read and write logic. On close, it pushes changes to space.Service

func OpenSpaceFilesHandler added in v0.1.3

func OpenSpaceFilesHandler(
	service SyncService,
	localFilePath,
	remoteFilePath,
	bucketName string,
) *SpaceFilesHandler

func (*SpaceFilesHandler) Close added in v0.1.3

func (s *SpaceFilesHandler) Close(ctx context.Context) error

func (*SpaceFilesHandler) Read added in v0.1.3

func (s *SpaceFilesHandler) Read(ctx context.Context, b []byte, offset int64) (int, error)

func (*SpaceFilesHandler) Stats added in v0.1.3

func (s *SpaceFilesHandler) Stats(ctx context.Context) (*DirEntry, error)

Stats for now always reads stats from local file

func (*SpaceFilesHandler) Truncate added in v0.1.3

func (s *SpaceFilesHandler) Truncate(ctx context.Context, size uint64) error

func (*SpaceFilesHandler) Write added in v0.1.3

func (s *SpaceFilesHandler) Write(ctx context.Context, b []byte, offset int64) (int, error)

type SyncService added in v0.1.3

type SyncService interface {
	AddItemWithReader(ctx context.Context, reader io.Reader, targetPath, bucketName string) (domain.AddItemResult, error)
}

type TLFDataSource added in v0.0.19

type TLFDataSource struct {
	FSDataSource
	// contains filtered or unexported fields
}

TLFDataSource represents a data source handler for a particular top level file.

func (*TLFDataSource) ChildPath added in v0.1.3

func (t *TLFDataSource) ChildPath(path string) string

Returns child path inside data source

func (*TLFDataSource) ParentPath added in v0.1.3

func (t *TLFDataSource) ParentPath(path string) string

returns the path with the datasource base path prefixed

Jump to

Keyboard shortcuts

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