fileinfostore

package
v0.5.9 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2022 License: LGPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	InitNs       = "Init"
	InfoNs       = "sharing"
	ShareIDNs    = "sharingKey"
	InitTimeKey  = "initTime"
	SchemaVerKey = "SchemaVersion"
	SchemaV1     = "v1"
)

Variables

View Source
var (
	ErrEmpty           = errors.New("can not hash empty string")
	ErrNotFound        = errors.New("file info not found")
	ErrSharingNotFound = errors.New("sharing id not found")
	ErrConflicted      = errors.New("conflict found in hashing")
	ErrVerNotFound     = errors.New("file info schema version not found")
)

Functions

func IsNotFound

func IsNotFound(err error) bool

Types

type FileInfo

type FileInfo struct {
	IsDir   bool   `json:"isDir"`
	Shared  bool   `json:"shared"`
	ShareID string `json:"shareID"` // for short url
	Sha1    string `json:"sha1"`
}

type FileInfoStore

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

func NewFileInfoStore

func NewFileInfoStore(store kvstore.IKVStore) (*FileInfoStore, error)

func (*FileInfoStore) AddSharing

func (fi *FileInfoStore) AddSharing(dirPath string) error

func (*FileInfoStore) DelInfo

func (fi *FileInfoStore) DelInfo(itemPath string) error

func (*FileInfoStore) DelSharing

func (fi *FileInfoStore) DelSharing(dirPath string) error

func (*FileInfoStore) GetInfo

func (fi *FileInfoStore) GetInfo(itemPath string) (*FileInfo, error)

func (*FileInfoStore) GetInfos

func (fi *FileInfoStore) GetInfos(itemPaths []string) (map[string]*FileInfo, error)

func (*FileInfoStore) GetSharing

func (fi *FileInfoStore) GetSharing(dirPath string) (bool, bool)

func (*FileInfoStore) GetSharingDir added in v0.5.0

func (fi *FileInfoStore) GetSharingDir(hashID string) (string, error)

func (*FileInfoStore) ListSharings

func (fi *FileInfoStore) ListSharings(prefix string) (map[string]string, error)

func (*FileInfoStore) SetInfo

func (fi *FileInfoStore) SetInfo(itemPath string, info *FileInfo) error

func (*FileInfoStore) SetSha1

func (fi *FileInfoStore) SetSha1(itemPath, sign string) error

type IFileInfoStore

type IFileInfoStore interface {
	AddSharing(dirPath string) error
	DelSharing(dirPath string) error
	GetSharing(dirPath string) (bool, bool)
	ListSharings(prefix string) (map[string]string, error)
	GetInfo(itemPath string) (*FileInfo, error)
	SetInfo(itemPath string, info *FileInfo) error
	DelInfo(itemPath string) error
	SetSha1(itemPath, sign string) error
	GetInfos(itemPaths []string) (map[string]*FileInfo, error)
	GetSharingDir(hashID string) (string, error)
}

Jump to

Keyboard shortcuts

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