fileref

package
v1.14.9 Latest Latest
Warning

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

Go to latest
Published: May 25, 2024 License: MIT Imports: 10 Imported by: 7

Documentation

Index

Constants

View Source
const (
	FILE      = "f"
	DIRECTORY = "d"
)
View Source
const CHUNK_SIZE = 64 * 1024

Variables

This section is empty.

Functions

func DeleteFileRef added in v1.14.0

func DeleteFileRef(key string)

func GetCacheKey added in v1.14.0

func GetCacheKey(lookuphash, blobberID string) string

func GetReferenceLookup

func GetReferenceLookup(allocationID string, path string) string

func StoreFileRef added in v1.14.0

func StoreFileRef(key string, fr FileRef)

Types

type Collaborator

type Collaborator struct {
	RefID     int64  `json:"ref_id"`
	ClientID  string `json:"client_id"`
	CreatedAt string `json:"created_at"`
}

type FileRef

type FileRef struct {
	Ref            `mapstructure:",squash"`
	CustomMeta     string `json:"custom_meta" mapstructure:"custom_meta"`
	ValidationRoot string `json:"validation_root" mapstructure:"validation_root"`
	// ValidationRootSignature is signature signed by client for hash_of(ActualFileHashSignature + ValidationRoot)
	ValidationRootSignature string `json:"validation_root_signature" mapstructure:"validation_root_signature"`
	FixedMerkleRoot         string `json:"fixed_merkle_root" mapstructure:"fixed_merkle_root"`
	ThumbnailSize           int64  `json:"thumbnail_size" mapstructure:"thumbnail_size"`
	ThumbnailHash           string `json:"thumbnail_hash" mapstructure:"thumbnail_hash"`
	ActualFileSize          int64  `json:"actual_file_size" mapstructure:"actual_file_size"`
	ActualFileHash          string `json:"actual_file_hash" mapstructure:"actual_file_hash"`
	// ActualFileHashSignature is signature signed by client for ActualFileHash
	ActualFileHashSignature string         `json:"actual_file_hash_signature" mapstructure:"actual_file_hash_signature"`
	ActualThumbnailSize     int64          `json:"actual_thumbnail_size" mapstructure:"actual_thumbnail_size"`
	ActualThumbnailHash     string         `json:"actual_thumbnail_hash" mapstructure:"actual_thumbnail_hash"`
	MimeType                string         `json:"mimetype" mapstructure:"mimetype"`
	EncryptedKey            string         `json:"encrypted_key" mapstructure:"encrypted_key"`
	EncryptedKeyPoint       string         `json:"encrypted_key_point" mapstructure:"encrypted_key_point"`
	Collaborators           []Collaborator `json:"collaborators" mapstructure:"collaborators"`
}

func GetFileRef added in v1.14.0

func GetFileRef(key string) (FileRef, bool)

func (*FileRef) CalculateHash

func (fr *FileRef) CalculateHash() string

func (*FileRef) GetCreatedAt

func (fr *FileRef) GetCreatedAt() common.Timestamp

func (*FileRef) GetFileID added in v1.8.13

func (fr *FileRef) GetFileID() string

func (*FileRef) GetFileMetaHash added in v1.8.13

func (fr *FileRef) GetFileMetaHash() string

func (*FileRef) GetFileMetaHashData added in v1.8.13

func (fr *FileRef) GetFileMetaHashData() string

func (*FileRef) GetHash

func (fr *FileRef) GetHash() string

func (*FileRef) GetHashData

func (fr *FileRef) GetHashData() string

func (*FileRef) GetLookupHash

func (fr *FileRef) GetLookupHash() string

func (*FileRef) GetName

func (fr *FileRef) GetName() string

func (*FileRef) GetNumBlocks

func (fr *FileRef) GetNumBlocks() int64

func (*FileRef) GetPath

func (fr *FileRef) GetPath() string

func (*FileRef) GetPathHash

func (fr *FileRef) GetPathHash() string

func (*FileRef) GetSize

func (fr *FileRef) GetSize() int64

func (*FileRef) GetType

func (fr *FileRef) GetType() string

func (*FileRef) GetUpdatedAt

func (fr *FileRef) GetUpdatedAt() common.Timestamp

func (*FileRef) MetaID added in v1.13.0

func (fRef *FileRef) MetaID() string

type Hashnode added in v1.7.3

type Hashnode struct {
	// hash data
	AllocationID    string `json:"allocation_id,omitempty"`
	Type            string `json:"type,omitempty"`
	Name            string `json:"name,omitempty"`
	Path            string `json:"path,omitempty"`
	ValidationRoot  string `json:"validation_root,omitempty"`
	FixedMerkleRoot string `json:"fixed_merkle_root,omitempty"`
	ActualFileHash  string `json:"actual_file_hash,omitempty"`
	ChunkSize       int64  `json:"chunk_size,omitempty"`
	Size            int64  `json:"size,omitempty"`
	ActualFileSize  int64  `json:"actual_file_size,omitempty"`

	Children []*Hashnode `json:"children,omitempty"`
	// contains filtered or unexported fields
}

Hashnode ref node in hash tree

func (*Hashnode) AddChild added in v1.7.3

func (n *Hashnode) AddChild(c *Hashnode)

func (*Hashnode) GetHashCode added in v1.7.3

func (n *Hashnode) GetHashCode() string

GetHashCode get hash code

func (*Hashnode) GetLookupHash added in v1.7.3

func (n *Hashnode) GetLookupHash() string

GetLookupHash get lookuphash

type ListResult

type ListResult struct {
	AllocationRoot string                   `json:"allocation_root"`
	Meta           map[string]interface{}   `json:"meta_data"`
	Entities       []map[string]interface{} `json:"list"`
}

func (*ListResult) GetDirTree

func (lr *ListResult) GetDirTree(allocationID string) (*Ref, error)

type Ref

type Ref struct {
	Type                string `json:"type" mapstructure:"type"`
	AllocationID        string `json:"allocation_id" mapstructure:"allocation_id"`
	Name                string `json:"name" mapstructure:"name"`
	Path                string `json:"path" mapstructure:"path"`
	Size                int64  `json:"size" mapstructure:"size"`
	ActualSize          int64  `json:"actual_file_size" mapstructure:"actual_file_size"`
	Hash                string `json:"hash" mapstructure:"hash"`
	ChunkSize           int64  `json:"chunk_size" mapstructure:"chunk_size"`
	NumBlocks           int64  `json:"num_of_blocks" mapstructure:"num_of_blocks"`
	PathHash            string `json:"path_hash" mapstructure:"path_hash"`
	LookupHash          string `json:"lookup_hash" mapstructure:"lookup_hash"`
	FileID              string `json:"file_id" mapstructure:"file_id"`
	FileMetaHash        string `json:"file_meta_hash" mapstructure:"file_meta_hash"`
	ThumbnailHash       string `json:"thumbnail_hash" mapstructure:"thumbnail_hash"`
	ThumbnailSize       int64  `json:"thumbnail_size" mapstructure:"thumbnail_size"`
	ActualThumbnailHash string `json:"actual_thumbnail_hash" mapstructure:"actual_thumbnail_hash"`
	ActualThumbnailSize int64  `json:"actual_thumbnail_size" mapstructure:"actual_thumbnail_size"`
	HashToBeComputed    bool
	ChildrenLoaded      bool
	Children            []RefEntity      `json:"-" mapstructure:"-"`
	CreatedAt           common.Timestamp `json:"created_at" mapstructure:"created_at"`
	UpdatedAt           common.Timestamp `json:"updated_at" mapstructure:"updated_at"`
}

func (*Ref) AddChild

func (r *Ref) AddChild(child RefEntity)

func (*Ref) CalculateHash

func (r *Ref) CalculateHash() string

func (*Ref) GetCreatedAt

func (r *Ref) GetCreatedAt() common.Timestamp

func (*Ref) GetFileID added in v1.8.13

func (r *Ref) GetFileID() string

func (*Ref) GetFileMetaHash added in v1.8.13

func (r *Ref) GetFileMetaHash() string

func (*Ref) GetHash

func (r *Ref) GetHash() string

func (*Ref) GetHashData added in v1.8.17

func (r *Ref) GetHashData() string

func (*Ref) GetLookupHash

func (r *Ref) GetLookupHash() string

func (*Ref) GetName

func (r *Ref) GetName() string

func (*Ref) GetNumBlocks

func (r *Ref) GetNumBlocks() int64

func (*Ref) GetPath

func (r *Ref) GetPath() string

func (*Ref) GetPathHash

func (r *Ref) GetPathHash() string

func (*Ref) GetSize

func (r *Ref) GetSize() int64

func (*Ref) GetType

func (r *Ref) GetType() string

func (*Ref) GetUpdatedAt

func (r *Ref) GetUpdatedAt() common.Timestamp

func (*Ref) RemoveChild

func (r *Ref) RemoveChild(idx int)

type RefEntity

type RefEntity interface {
	GetNumBlocks() int64
	GetSize() int64
	GetFileMetaHash() string
	GetHash() string
	CalculateHash() string
	GetType() string
	GetPathHash() string
	GetLookupHash() string
	GetPath() string
	GetName() string
	GetFileID() string
	GetCreatedAt() common.Timestamp
	GetUpdatedAt() common.Timestamp
}

type ReferencePath

type ReferencePath struct {
	Meta map[string]interface{} `json:"meta_data"`
	List []*ReferencePath       `json:"list,omitempty"`
}

func (*ReferencePath) GetDirTree

func (rp *ReferencePath) GetDirTree(allocationID string) (*Ref, error)

GetDirTree covert and build root Ref with children

func (*ReferencePath) GetRefFromObjectTree

func (rp *ReferencePath) GetRefFromObjectTree(allocationID string) (RefEntity, error)

Jump to

Keyboard shortcuts

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