model

package
v1.18.15 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// FileRef represents a file
	FILE = "f"

	// FileRef represents a directory
	DIRECTORY = "d"

	CHUNK_SIZE = 64 * 1024

	DIR_LIST_TAG  = "dirlist"
	FILE_LIST_TAG = "filelist"
)

Variables

This section is empty.

Functions

func GetListingFieldsMap

func GetListingFieldsMap(refEntity interface{}, tagName string) map[string]interface{}

func GetReferenceLookup

func GetReferenceLookup(allocationID string, path string) string

GetReferenceLookup hash(allocationID + ":" + path) which is used to lookup the file reference in the db.

  • allocationID is the allocation ID.
  • path is the path of the file.

func GetSubDirsFromPath

func GetSubDirsFromPath(p string) []string

Types

type CommitResult

type CommitResult struct {
	AllocationRoot string       `json:"allocation_root"`
	WriteMarker    *WriteMarker `json:"write_marker"`
	Success        bool         `json:"success"`
	ErrorMessage   string       `json:"error_msg,omitempty"`
}

type LatestPrevWriteMarker added in v1.8.17

type LatestPrevWriteMarker struct {
	LatestWM *marker.WriteMarker `json:"latest_write_marker"`
	PrevWM   *marker.WriteMarker `json:"prev_write_marker"`
}

type Ref

type Ref struct {
	Type            string `gorm:"column:type" dirlist:"type" filelist:"type"`
	AllocationID    string `gorm:"column:allocation_id"`
	LookupHash      string `gorm:"column:lookup_hash" dirlist:"lookup_hash" filelist:"lookup_hash"`
	Name            string `gorm:"column:name" dirlist:"name" filelist:"name"`
	Path            string `gorm:"column:path" dirlist:"path" filelist:"path"`
	Hash            string `gorm:"column:hash" dirlist:"hash" filelist:"hash"`
	NumBlocks       int64  `gorm:"column:num_of_blocks" dirlist:"num_of_blocks" filelist:"num_of_blocks"`
	PathHash        string `gorm:"column:path_hash" dirlist:"path_hash" filelist:"path_hash"`
	ParentPath      string `gorm:"column:parent_path"`
	PathLevel       int    `gorm:"column:level"`
	ValidationRoot  string `gorm:"column:validation_root" filelist:"validation_root"`
	Size            int64  `gorm:"column:size" dirlist:"size" filelist:"size"`
	FixedMerkleRoot string `gorm:"column:fixed_merkle_root" filelist:"fixed_merkle_root"`
	ActualFileSize  int64  `gorm:"column:actual_file_size" filelist:"actual_file_size"`
	ActualFileHash  string `gorm:"column:actual_file_hash" filelist:"actual_file_hash"`

	Children []*Ref `gorm:"-"`

	ChunkSize int64 `gorm:"column:chunk_size" dirlist:"chunk_size" filelist:"chunk_size"`
	// contains filtered or unexported fields
}

func (*Ref) CalculateDirHash

func (r *Ref) CalculateDirHash(ctx context.Context) (string, error)

func (*Ref) CalculateFileHash

func (fr *Ref) CalculateFileHash(ctx context.Context) (string, error)

func (*Ref) CalculateHash

func (r *Ref) CalculateHash(ctx context.Context) (string, error)

func (*Ref) GetFileHashData

func (fr *Ref) GetFileHashData() string

func (*Ref) GetListingData

func (r *Ref) GetListingData(ctx context.Context) map[string]interface{}

GetListingData reflect and convert all fields into map[string]interface{}

type ReferencePath

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

type ReferencePathResult

type ReferencePathResult struct {
	*ReferencePath
	LatestWM *WriteMarker `json:"latest_write_marker"`
}

func BuildReferencePathResult

func BuildReferencePathResult(rootRef *Ref) *ReferencePathResult

type UploadFormData

type UploadFormData struct {
	ConnectionID string `json:"connection_id,omitempty"`
	// Filename remote file name
	Filename string `json:"filename,omitempty"`
	// Path remote path
	Path string `json:"filepath,omitempty"`

	// ValidationRoot of shard data (encoded,encrypted) where leaf is sha256 hash of 64KB data
	ValidationRoot string `json:"validation_root,omitempty"`
	// Hash hash of shard thumbnail  (encoded,encrypted)
	ThumbnailContentHash string `json:"thumbnail_content_hash,omitempty"`

	// FixedMerkleRoot merkle root of shard data (encoded, encrypted)
	FixedMerkleRoot string `json:"fixed_merkle_root,omitempty"`

	// ActualHash hash of orignial file (unencoded, unencrypted)
	ActualHash string `json:"actual_hash,omitempty"`
	// ActualSize total bytes of  orignial file (unencoded, unencrypted)
	ActualSize int64 `json:"actual_size,omitempty"`
	// ActualThumbnailSize total bytes of orignial thumbnail (unencoded, unencrypted)
	ActualThumbSize int64 `json:"actual_thumb_size,omitempty"`
	// ActualThumbnailHash hash of orignial thumbnail (unencoded, unencrypted)
	ActualThumbHash string `json:"actual_thumb_hash,omitempty"`

	MimeType     string `json:"mimetype,omitempty"`
	CustomMeta   string `json:"custom_meta,omitempty"`
	EncryptedKey string `json:"encrypted_key,omitempty"`

	IsFinal      bool   `json:"is_final,omitempty"`      // current chunk is last or not
	ChunkHash    string `json:"chunk_hash"`              // hash of current chunk
	ChunkIndex   int    `json:"chunk_index,omitempty"`   // the seq of current chunk. all chunks MUST be uploaded one by one because of streaming merkle hash
	ChunkSize    int64  `json:"chunk_size,omitempty"`    // the size of a chunk. 64*1024 is default
	UploadOffset int64  `json:"upload_offset,omitempty"` // It is next position that new incoming chunk should be append to

}

UploadFormData form data of upload

type UploadResult

type UploadResult struct {
	Filename        string `json:"filename"`
	ShardSize       int64  `json:"size"`
	ValidationRoot  string `json:"validation_root,omitempty"`
	FixedMerkleRoot string `json:"fixed_merkle_root,omitempty"`
}

type WriteMarker

type WriteMarker struct {
	AllocationRoot         string           `gorm:"column:allocation_root;primary_key" json:"allocation_root"`
	PreviousAllocationRoot string           `gorm:"column:prev_allocation_root" json:"prev_allocation_root"`
	AllocationID           string           `gorm:"column:allocation_id" json:"allocation_id"`
	Size                   int64            `gorm:"column:size" json:"size"`
	BlobberID              string           `gorm:"column:blobber_id" json:"blobber_id"`
	Timestamp              common.Timestamp `gorm:"column:timestamp" json:"timestamp"`
	ClientID               string           `gorm:"column:client_id" json:"client_id"`
	Signature              string           `gorm:"column:signature" json:"signature"`
}

Jump to

Keyboard shortcuts

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