# README
reference
import "github.com/0chain/blobber/code/go/0chain.net/blobbercore/reference"
Index
- Constants
- func AddShareInfo(ctx context.Context, shareInfo *ShareInfo) error
- func CountRefs(ctx context.Context, allocationID string) (int64, error)
- func DeleteFileStats(ctx context.Context, refID int64) error
- func DeleteObject(ctx context.Context, rootRef *Ref, allocationID, objPath string, ts common.Timestamp) error
- func DeleteReference(ctx context.Context, refID int64, pathHash string) error
- func DeleteShareInfo(ctx context.Context, shareInfo *ShareInfo) error
- func FileBlockDownloaded(ctx context.Context, ref *Ref, blocks int64)
- func FileUpdated(ctx context.Context, refID, newRefID int64)
- func GetListingFieldsMap(refEntity interface{}, tagName string) map[string]interface{}
- func GetReferenceLookup(allocationID, path string) string
- func GetRefs(ctx context.Context, allocationID, path, offsetPath, _type string, level, pageLimit int) (refs *[]PaginatedRef, totalPages int, newOffsetPath string, err error)
- func GetSubDirsFromPath(p string) []string
- func GetUpdatedRefs(ctx context.Context, allocationID, path, offsetPath, _type, updatedDate, offsetDate string, level, pageLimit int, dateLayOut string) (refs *[]PaginatedRef, totalPages int, newOffsetPath string, newOffsetDate common.Timestamp, err error)
- func IsRefExist(ctx context.Context, allocationID, path string) (bool, error)
- func NewDirCreated(ctx context.Context, refID int64)
- func NewFileCreated(ctx context.Context, refID int64)
- func UpdateShareInfo(ctx context.Context, shareInfo *ShareInfo) error
- type FileStats
- type Hashnode
- type ObjectPath
- type PaginatedRef
- type PlaylistFile
- type QueryCollector
- type Ref
- func GetLimitedRefFieldsByLookupHash(ctx context.Context, allocationID, lookupHash string, selectedFields []string) (*Ref, error)
- func GetLimitedRefFieldsByLookupHashWith(ctx context.Context, allocationID, lookupHash string, selectedFields []string) (*Ref, error)
- func GetLimitedRefFieldsByPath(ctx context.Context, allocationID, path string, selectedFields []string) (*Ref, error)
- func GetObjectTree(ctx context.Context, allocationID, path string) (*Ref, error)
- func GetRefWithChildren(ctx context.Context, parentRef *Ref, allocationID, path string, offset, pageLimit int) (*Ref, error)
- func GetRefWithDirListFields(ctx context.Context, pathHash string) (*Ref, error)
- func GetRefWithSortedChildren(ctx context.Context, allocationID, path string) (*Ref, error)
- func GetReference(ctx context.Context, allocationID, path string) (*Ref, error)
- func GetReferenceByLookupHash(ctx context.Context, allocationID, pathHash string) (*Ref, error)
- func GetReferenceByLookupHashForDownload(ctx context.Context, allocationID, pathHash string) (*Ref, error)
- func GetReferenceForHashCalculationFromPaths(ctx context.Context, allocationID string, paths []string) (*Ref, error)
- func GetReferencePath(ctx context.Context, allocationID, path string) (*Ref, error)
- func GetReferencePathFromPaths(ctx context.Context, allocationID string, paths, objTreePath []string) (*Ref, error)
- func GetReferencesByName(ctx context.Context, allocationID, name string) (refs []*Ref, err error)
- func GetRefsTypeFromPaths(ctx context.Context, allocationID string, paths []string) (refs []*Ref, err error)
- func ListingDataToRef(refMap map[string]interface{}) *Ref
- func Mkdir(ctx context.Context, allocationID, destpath string) (*Ref, error)
- func NewDirectoryRef() *Ref
- func NewFileRef() *Ref
- func (r *Ref) AddChild(child *Ref)
- func (ref *Ref) BeforeCreate(tx *gorm.DB) (err error)
- func (ref *Ref) BeforeSave(tx *gorm.DB) (err error)
- func (r *Ref) CalculateDirHash(ctx context.Context, saveToDB bool, collector QueryCollector) (h string, err error)
- func (fr *Ref) CalculateFileHash(ctx context.Context, saveToDB bool, collector QueryCollector) (string, error)
- func (r *Ref) CalculateHash(ctx context.Context, saveToDB bool, collector QueryCollector) (string, error)
- func (fr *Ref) GetFileHashData() string
- func (r *Ref) GetFileMetaHashData() string
- func (r *Ref) GetHashData() string
- func (r *Ref) GetListingData(ctx context.Context) map[string]interface{}
- func (rootRef *Ref) GetSrcPath(path string) (*Ref, error)
- func (r *Ref) RemoveChild(idx int)
- func (r *Ref) Save(ctx context.Context) error
- func (r *Ref) SaveDirRef(ctx context.Context, collector QueryCollector) error
- func (r *Ref) SaveFileRef(ctx context.Context, collector QueryCollector) error
- func (Ref) TableName() string
- func (r *Ref) UpdatePath(newPath, parentPath string)
- type ReferencePath
- type ShareInfo
Constants
const (
FILE = "f"
DIRECTORY = "d"
CHUNK_SIZE = 64 * 1024
DIR_LIST_TAG = "dirlist"
FILE_LIST_TAG = "filelist"
)
const (
TableNameReferenceObjects = "reference_objects"
)
func AddShareInfo
func AddShareInfo(ctx context.Context, shareInfo *ShareInfo) error
add share if it already doesnot exist
func CountRefs
func CountRefs(ctx context.Context, allocationID string) (int64, error)
func DeleteFileStats
func DeleteFileStats(ctx context.Context, refID int64) error
func DeleteObject
func DeleteObject(ctx context.Context, rootRef *Ref, allocationID, objPath string, ts common.Timestamp) error
func DeleteReference
func DeleteReference(ctx context.Context, refID int64, pathHash string) error
func DeleteShareInfo
func DeleteShareInfo(ctx context.Context, shareInfo *ShareInfo) error
func FileBlockDownloaded
func FileBlockDownloaded(ctx context.Context, ref *Ref, blocks int64)
func FileUpdated
func FileUpdated(ctx context.Context, refID, newRefID int64)
func GetListingFieldsMap
func GetListingFieldsMap(refEntity interface{}, tagName string) map[string]interface{}
func GetReferenceLookup
func GetReferenceLookup(allocationID, path string) string
GetReferenceLookup hash(allocationID + ":" + path)
func GetRefs
func GetRefs(ctx context.Context, allocationID, path, offsetPath, _type string, level, pageLimit int) (refs *[]PaginatedRef, totalPages int, newOffsetPath string, err error)
This function retrieves reference_objects tables rows with pagination. Check for issue https://github.com/0chain/gosdk/issues/117 Might need to consider covering index for efficient search https://blog.crunchydata.com/blog/why-covering-indexes-are-incredibly-helpful To retrieve refs efficiently form pagination index is created in postgresql on path column so it can be used to paginate refs very easily and effectively; Same case for offsetDate.
func GetSubDirsFromPath
func GetSubDirsFromPath(p string) []string
func GetUpdatedRefs
func GetUpdatedRefs(ctx context.Context, allocationID, path, offsetPath, _type, updatedDate, offsetDate string, level, pageLimit int, dateLayOut string) (refs *[]PaginatedRef, totalPages int, newOffsetPath string, newOffsetDate common.Timestamp, err error)
Retrieves updated refs compared to some update_at value. Useful to localCache
func IsRefExist
func IsRefExist(ctx context.Context, allocationID, path string) (bool, error)
IsRefExist checks if ref with given path exists and returns error other than gorm.ErrRecordNotFound
func NewDirCreated
func NewDirCreated(ctx context.Context, refID int64)
func NewFileCreated
func NewFileCreated(ctx context.Context, refID int64)
func UpdateShareInfo
func UpdateShareInfo(ctx context.Context, shareInfo *ShareInfo) error
type FileStats
type FileStats struct {
ID int64 `gorm:"column:id;primaryKey" json:"-"`
RefID int64 `gorm:"column:ref_id;unique" json:"-"`
Ref Ref `gorm:"foreignKey:RefID;constraint:OnDelete:CASCADE"`
NumUpdates int64 `gorm:"column:num_of_updates" json:"num_of_updates"`
NumBlockDownloads int64 `gorm:"column:num_of_block_downloads" json:"num_of_block_downloads"`
SuccessChallenges int64 `gorm:"column:num_of_challenges" json:"num_of_challenges"`
FailedChallenges int64 `gorm:"column:num_of_failed_challenges" json:"num_of_failed_challenges"`
LastChallengeResponseTxn string `gorm:"column:last_challenge_txn;size:64" json:"last_challenge_txn"`
WriteMarkerRedeemTxn string `gorm:"-" json:"write_marker_txn"`
OnChain bool `gorm:"-" json:"on_chain"`
DeletedAt gorm.DeletedAt `gorm:"column:deleted_at"` // soft deletion
datastore.ModelWithTS
}
func GetFileStats
func GetFileStats(ctx context.Context, ref *Ref) (*FileStats, error)
func (*FileStats) BeforeCreate
func (f *FileStats) BeforeCreate(tx *gorm.DB) error
func (*FileStats) BeforeSave
func (f *FileStats) BeforeSave(tx *gorm.DB) error
func (FileStats) TableName
func (FileStats) TableName() string
type Hashnode
Hashnode ref node in hash tree
type Hashnode struct {
// hash data
AllocationID string `gorm:"column:allocation_id" json:"allocation_id,omitempty"`
Type string `gorm:"column:type" json:"type,omitempty"`
Name string `gorm:"column:name" json:"name,omitempty"`
Path string `gorm:"column:path" json:"path,omitempty"`
ValidationRoot string `gorm:"column:validation_root" json:"validation_root,omitempty"`
FixedMerkleRoot string `gorm:"column:fixed_merkle_root" json:"fixed_merkle_root,omitempty"`
ActualFileHash string `gorm:"column:actual_file_hash" json:"actual_file_hash,omitempty"`
ChunkSize int64 `gorm:"column:chunk_size" json:"chunk_size,omitempty"`
Size int64 `gorm:"column:size" json:"size,omitempty"`
ActualFileSize int64 `gorm:"column:actual_file_size" json:"actual_file_size,omitempty"`
// other data
ParentPath string `gorm:"parent_path" json:"-"`
Children []*Hashnode `gorm:"-" json:"children,omitempty"`
}
func LoadRootHashnode
func LoadRootHashnode(ctx context.Context, allocationID string) (*Hashnode, error)
LoadRootHashnode load root node with its descendant nodes
func (*Hashnode) AddChild
func (n *Hashnode) AddChild(c *Hashnode)
func (*Hashnode) GetLookupHash
func (n *Hashnode) GetLookupHash() string
GetLookupHash get lookuphash
func (Hashnode) TableName
func (Hashnode) TableName() string
TableName get table name of Ref
type ObjectPath
type ObjectPath struct {
RootHash string `json:"root_hash"`
Meta map[string]interface{} `json:"meta_data"`
Path map[string]interface{} `json:"path"`
FileBlockNum int64 `json:"file_block_num"`
ChunkSize int64 `json:"chunk_size"`
Size int64 `json:"size"`
RefID int64 `json:"-"`
}
func GetObjectPath
func GetObjectPath(ctx context.Context, allocationID string, blockNum int64) (*ObjectPath, error)
TODO needs to be refactored, current implementation can probably be heavily simplified
type PaginatedRef
type PaginatedRef struct {
ID int64 `gorm:"column:id" json:"id,omitempty"`
FileID string `gorm:"file_id" json:"file_id"`
Type string `gorm:"column:type" json:"type,omitempty"`
AllocationID string `gorm:"column:allocation_id" json:"allocation_id,omitempty"`
LookupHash string `gorm:"column:lookup_hash" json:"lookup_hash,omitempty"`
Name string `gorm:"column:name" json:"name,omitempty"`
Path string `gorm:"column:path" json:"path,omitempty"`
Hash string `gorm:"column:hash" json:"hash,omitempty"`
NumBlocks int64 `gorm:"column:num_of_blocks" json:"num_blocks,omitempty"`
PathHash string `gorm:"column:path_hash" json:"path_hash,omitempty"`
ParentPath string `gorm:"column:parent_path" json:"parent_path,omitempty"`
PathLevel int `gorm:"column:level" json:"level,omitempty"`
CustomMeta string `gorm:"column:custom_meta" json:"custom_meta,omitempty"`
ValidationRootSignature string `gorm:"column:validation_root_signature" json:"validation_root_signature,omitempty"`
ValidationRoot string `gorm:"column:validation_root" json:"validation_root,omitempty"`
Size int64 `gorm:"column:size" json:"size,omitempty"`
FixedMerkleRoot string `gorm:"column:fixed_merkle_root" json:"fixed_merkle_root,omitempty"`
ActualFileSize int64 `gorm:"column:actual_file_size" json:"actual_file_size,omitempty"`
ActualFileHashSignature string `gorm:"column:actual_file_hash_signature" json:"actual_file_hash_signature,omitempty"`
ActualFileHash string `gorm:"column:actual_file_hash" json:"actual_file_hash,omitempty"`
MimeType string `gorm:"column:mimetype" json:"mimetype,omitempty"`
AllocationRoot string `gorm:"column:allocation_root" json:"allocation_root,omitempty"`
ThumbnailSize int64 `gorm:"column:thumbnail_size" json:"thumbnail_size,omitempty"`
ThumbnailHash string `gorm:"column:thumbnail_hash" json:"thumbnail_hash,omitempty"`
ActualThumbnailSize int64 `gorm:"column:actual_thumbnail_size" json:"actual_thumbnail_size,omitempty"`
ActualThumbnailHash string `gorm:"column:actual_thumbnail_hash" json:"actual_thumbnail_hash,omitempty"`
EncryptedKey string `gorm:"column:encrypted_key" json:"encrypted_key,omitempty"`
EncryptedKeyPoint string `gorm:"column:encrypted_key_point" json:"encrypted_key_point,omitempty"`
CreatedAt common.Timestamp `gorm:"column:created_at" json:"created_at,omitempty"`
UpdatedAt common.Timestamp `gorm:"column:updated_at" json:"updated_at,omitempty"`
ChunkSize int64 `gorm:"column:chunk_size" json:"chunk_size"`
}
func GetRecentlyCreatedRefs
func GetRecentlyCreatedRefs(ctx context.Context, allocID string, pageLimit, offset, fromDate int) (refs []*PaginatedRef, newOffset int, err error)
GetRecentlyCreatedRefs will return recently created refs with pagination. As opposed to getting refs ordered by path in ascending order, this will return paths in decending order for same timestamp. So if a file is created with path "/a/b/c/d/e/f.txt" and if "/a" didn't exist previously then creation date for "/a", "/a/b", "/a/b/c", "/a/b/c/d", "/a/b/c/d/e" and "/a/b/c/d/e/f.txt" will be the same. The refs returned will be in "/a/b/c/d/e/f.txt", "/a/b/c/d/e", ... order.
pageLimit --> maximum number of refs to return fromDate --> timestamp to begin searching refs from i.e. refs created date greater than fromDate newOffset --> offset to use for subsequent request
type PlaylistFile
type PlaylistFile struct {
LookupHash string `gorm:"column:lookup_hash" json:"lookup_hash"`
Name string `gorm:"column:name" json:"name"`
Path string `gorm:"column:path" json:"path"`
NumBlocks int64 `gorm:"column:num_of_blocks" json:"num_of_blocks"`
ParentPath string `gorm:"column:parent_path" json:"parent_path"`
Size int64 `gorm:"column:size;" json:"size"`
MimeType string `gorm:"column:mimetype" json:"mimetype"`
Type string `gorm:"column:type" json:"type"`
}
func LoadPlaylist
func LoadPlaylist(ctx context.Context, allocationID, path, since string) ([]PlaylistFile, error)
LoadPlaylist load playlist
func LoadPlaylistFile
func LoadPlaylistFile(ctx context.Context, allocationID, lookupHash string) (*PlaylistFile, error)
type QueryCollector
type QueryCollector interface {
CreateRefRecord(ref *Ref)
DeleteRefRecord(ref *Ref)
Finalize(ctx context.Context) error
}
func NewCollector
func NewCollector(changes int) QueryCollector
type Ref
type Ref struct {
ID int64 `gorm:"column:id;primaryKey"`
FileID string `gorm:"column:file_id" dirlist:"file_id" filelist:"file_id"`
Type string `gorm:"column:type;size:1" dirlist:"type" filelist:"type"`
AllocationID string `gorm:"column:allocation_id;size:64;not null;index:idx_path_alloc,priority:1;index:idx_parent_path_alloc,priority:1;index:idx_validation_alloc,priority:1" dirlist:"allocation_id" filelist:"allocation_id"`
LookupHash string `gorm:"column:lookup_hash;size:64;not null;index:idx_lookup_hash" dirlist:"lookup_hash" filelist:"lookup_hash"`
Name string `gorm:"column:name;size:100;not null;index:idx_name_gin" dirlist:"name" filelist:"name"` // uses GIN tsvector index for full-text search
Path string `gorm:"column:path;size:1000;not null;index:idx_path_alloc,priority:2;index:path_idx;index:idx_path_gin_trgm" dirlist:"path" filelist:"path"`
FileMetaHash string `gorm:"column:file_meta_hash;size:64;not null" dirlist:"file_meta_hash" filelist:"file_meta_hash"`
Hash string `gorm:"column:hash;size:64;not null" dirlist:"hash" filelist:"hash"`
NumBlocks int64 `gorm:"column:num_of_blocks;not null;default:0" dirlist:"num_of_blocks" filelist:"num_of_blocks"`
PathHash string `gorm:"column:path_hash;size:64;not null" dirlist:"path_hash" filelist:"path_hash"`
ParentPath string `gorm:"column:parent_path;size:999;index:idx_parent_path_alloc,priority:2"`
PathLevel int `gorm:"column:level;not null;default:0"`
CustomMeta string `gorm:"column:custom_meta;not null" filelist:"custom_meta"`
ValidationRoot string `gorm:"column:validation_root;size:64;not null;index:idx_validation_alloc,priority:2" filelist:"validation_root"`
PrevValidationRoot string `gorm:"column:prev_validation_root" filelist:"prev_validation_root" json:"prev_validation_root"`
ValidationRootSignature string `gorm:"column:validation_root_signature;size:64" filelist:"validation_root_signature" json:"validation_root_signature,omitempty"`
Size int64 `gorm:"column:size;not null;default:0" dirlist:"size" filelist:"size"`
FixedMerkleRoot string `gorm:"column:fixed_merkle_root;size:64;not null" filelist:"fixed_merkle_root"`
ActualFileSize int64 `gorm:"column:actual_file_size;not null;default:0" dirlist:"actual_file_size" filelist:"actual_file_size"`
ActualFileHashSignature string `gorm:"column:actual_file_hash_signature;size:64" filelist:"actual_file_hash_signature" json:"actual_file_hash_signature,omitempty"`
ActualFileHash string `gorm:"column:actual_file_hash;size:64;not null" filelist:"actual_file_hash"`
MimeType string `gorm:"column:mimetype;size:255;not null" filelist:"mimetype"`
AllocationRoot string `gorm:"column:allocation_root;size:64;not null"`
ThumbnailSize int64 `gorm:"column:thumbnail_size;not null;default:0" filelist:"thumbnail_size"`
ThumbnailHash string `gorm:"column:thumbnail_hash;size:64;not null" filelist:"thumbnail_hash"`
PrevThumbnailHash string `gorm:"column:prev_thumbnail_hash" filelist:"prev_thumbnail_hash"`
ActualThumbnailSize int64 `gorm:"column:actual_thumbnail_size;not null;default:0" filelist:"actual_thumbnail_size"`
ActualThumbnailHash string `gorm:"column:actual_thumbnail_hash;size:64;not null" filelist:"actual_thumbnail_hash"`
EncryptedKey string `gorm:"column:encrypted_key;size:64" filelist:"encrypted_key"`
EncryptedKeyPoint string `gorm:"column:encrypted_key_point;size:64" filelist:"encrypted_key_point"`
Children []*Ref `gorm:"-"`
CreatedAt common.Timestamp `gorm:"column:created_at;index:idx_created_at,sort:desc" dirlist:"created_at" filelist:"created_at"`
UpdatedAt common.Timestamp `gorm:"column:updated_at;index:idx_updated_at,sort:desc;" dirlist:"updated_at" filelist:"updated_at"`
DeletedAt gorm.DeletedAt `gorm:"column:deleted_at"` // soft deletion
IsPrecommit bool `gorm:"column:is_precommit;not null;default:false" filelist:"is_precommit" dirlist:"is_precommit"`
ChunkSize int64 `gorm:"column:chunk_size;not null;default:65536" dirlist:"chunk_size" filelist:"chunk_size"`
NumUpdates int64 `gorm:"column:num_of_updates" json:"num_of_updates"`
NumBlockDownloads int64 `gorm:"column:num_of_block_downloads" json:"num_of_block_downloads"`
HashToBeComputed bool `gorm:"-"`
// contains filtered or unexported fields
}
func GetLimitedRefFieldsByLookupHash
func GetLimitedRefFieldsByLookupHash(ctx context.Context, allocationID, lookupHash string, selectedFields []string) (*Ref, error)
GetLimitedRefFieldsByLookupHash get FileRef selected fields with allocationID and lookupHash from postgres
func GetLimitedRefFieldsByLookupHashWith
func GetLimitedRefFieldsByLookupHashWith(ctx context.Context, allocationID, lookupHash string, selectedFields []string) (*Ref, error)
GetLimitedRefFieldsByLookupHash get FileRef selected fields with allocationID and lookupHash from postgres
func GetLimitedRefFieldsByPath
func GetLimitedRefFieldsByPath(ctx context.Context, allocationID, path string, selectedFields []string) (*Ref, error)
GetLimitedRefFieldsByPath get FileRef selected fields with allocationID and path from postgres
func GetObjectTree
func GetObjectTree(ctx context.Context, allocationID, path string) (*Ref, error)
func GetRefWithChildren
func GetRefWithChildren(ctx context.Context, parentRef *Ref, allocationID, path string, offset, pageLimit int) (*Ref, error)
func GetRefWithDirListFields
func GetRefWithDirListFields(ctx context.Context, pathHash string) (*Ref, error)
func GetRefWithSortedChildren
func GetRefWithSortedChildren(ctx context.Context, allocationID, path string) (*Ref, error)
func GetReference
func GetReference(ctx context.Context, allocationID, path string) (*Ref, error)
GetReference get FileRef with allcationID and path from postgres
func GetReferenceByLookupHash
func GetReferenceByLookupHash(ctx context.Context, allocationID, pathHash string) (*Ref, error)
func GetReferenceByLookupHashForDownload
func GetReferenceByLookupHashForDownload(ctx context.Context, allocationID, pathHash string) (*Ref, error)
func GetReferenceForHashCalculationFromPaths
func GetReferenceForHashCalculationFromPaths(ctx context.Context, allocationID string, paths []string) (*Ref, error)
GetReferenceForHashCalculationFromPaths validate and build full dir tree from db, and CalculateHash and return root Ref without saving in DB
func GetReferencePath
func GetReferencePath(ctx context.Context, allocationID, path string) (*Ref, error)
func GetReferencePathFromPaths
func GetReferencePathFromPaths(ctx context.Context, allocationID string, paths, objTreePath []string) (*Ref, error)
GetReferencePathFromPaths validate and build full dir tree from db, and CalculateHash and return root Ref
func GetReferencesByName
func GetReferencesByName(ctx context.Context, allocationID, name string) (refs []*Ref, err error)
func GetRefsTypeFromPaths
func GetRefsTypeFromPaths(ctx context.Context, allocationID string, paths []string) (refs []*Ref, err error)
GetRefsTypeFromPaths Give list of paths it will return refs of respective path with only Type and Path selected in sql query
func ListingDataToRef
func ListingDataToRef(refMap map[string]interface{}) *Ref
func Mkdir
func Mkdir(ctx context.Context, allocationID, destpath string) (*Ref, error)
Mkdir create dirs if they don't exits. do nothing if dir exists. last dir will be return without child
func NewDirectoryRef
func NewDirectoryRef() *Ref
func NewFileRef
func NewFileRef() *Ref
func (*Ref) AddChild
func (r *Ref) AddChild(child *Ref)
func (*Ref) BeforeCreate
func (ref *Ref) BeforeCreate(tx *gorm.DB) (err error)
BeforeCreate Hook that gets executed to update create and update date
func (*Ref) BeforeSave
func (ref *Ref) BeforeSave(tx *gorm.DB) (err error)
func (*Ref) CalculateDirHash
func (r *Ref) CalculateDirHash(ctx context.Context, saveToDB bool, collector QueryCollector) (h string, err error)
func (*Ref) CalculateFileHash
func (fr *Ref) CalculateFileHash(ctx context.Context, saveToDB bool, collector QueryCollector) (string, error)
func (*Ref) CalculateHash
func (r *Ref) CalculateHash(ctx context.Context, saveToDB bool, collector QueryCollector) (string, error)
func (*Ref) GetFileHashData
func (fr *Ref) GetFileHashData() string
func (*Ref) GetFileMetaHashData
func (r *Ref) GetFileMetaHashData() string
func (*Ref) GetHashData
func (r *Ref) GetHashData() string
func (*Ref) GetListingData
func (r *Ref) GetListingData(ctx context.Context) map[string]interface{}
GetListingData reflect and convert all fields into map[string]interface{}
func (*Ref) GetSrcPath
func (rootRef *Ref) GetSrcPath(path string) (*Ref, error)
func (*Ref) RemoveChild
func (r *Ref) RemoveChild(idx int)
func (*Ref) Save
func (r *Ref) Save(ctx context.Context) error
func (*Ref) SaveDirRef
func (r *Ref) SaveDirRef(ctx context.Context, collector QueryCollector) error
func (*Ref) SaveFileRef
func (r *Ref) SaveFileRef(ctx context.Context, collector QueryCollector) error
func (Ref) TableName
func (Ref) TableName() string
func (*Ref) UpdatePath
func (r *Ref) UpdatePath(newPath, parentPath string)
type ReferencePath
type ReferencePath struct {
Meta map[string]interface{} `json:"meta_data"`
List []*ReferencePath `json:"list,omitempty"`
Ref *Ref
}
type ShareInfo
type ShareInfo struct {
ID int `gorm:"column:id;primaryKey"`
OwnerID string `gorm:"column:owner_id;size:64;not null;index:idx_marketplace_share_info_for_owner,priority:1" json:"owner_id,omitempty"`
ClientID string `gorm:"column:client_id;size:64;not null;index:idx_marketplace_share_info_for_client,priority:1" json:"client_id"`
FilePathHash string `gorm:"column:file_path_hash;size:64;not null;index:idx_marketplace_share_info_for_owner,priority:2;index:idx_marketplace_share_info_for_client,priority:2" json:"file_path_hash,omitempty"`
ReEncryptionKey string `gorm:"column:re_encryption_key;not null" json:"re_encryption_key,omitempty"`
ClientEncryptionPublicKey string `gorm:"column:client_encryption_public_key;not null" json:"client_encryption_public_key,omitempty"`
Revoked bool `gorm:"column:revoked;not null" json:"revoked"`
ExpiryAt time.Time `gorm:"column:expiry_at;not null" json:"expiry_at,omitempty"`
AvailableAt time.Time `gorm:"column:available_at;type:timestamp without time zone;not null;default:current_timestamp" json:"available_at,omitempty"`
}
func GetShareInfo
func GetShareInfo(ctx context.Context, clientID, filePathHash string) (*ShareInfo, error)
func ListShareInfoClientID
func ListShareInfoClientID(ctx context.Context, ownerID string, limit common.Pagination) ([]ShareInfo, error)
ListShareInfo returns list of files by a given clientID
func (ShareInfo) TableName
func (ShareInfo) TableName() string
Generated by gomarkdoc