GlobalStore

package
v0.0.0-...-be7a3bd Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2023 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const EmptyString = ""
View Source
const Separator = string(filepath.Separator)

Variables

This section is empty.

Functions

func IgnoreDotExternalPath

func IgnoreDotExternalPath(relPath string, info os.FileInfo) bool

func IgnoreDotGitPath

func IgnoreDotGitPath(relPath string, info os.FileInfo) bool

func ReleaseFileInfo

func ReleaseFileInfo(fi *FileInfo)

func ReleaseFileInfoMap

func ReleaseFileInfoMap(m FileInfoMap)

Types

type FileInfo

type FileInfo struct {
	//日期
	CheckedAt int64 `json:"checked_at"`
	//完整性校验
	Integrity Integrity `json:"integrity"`
	//权限
	Mode int `json:"mode"`
	//文件大小
	Size int64 `json:"size"`
}

func AcquireFileInfo

func AcquireFileInfo() *FileInfo

func (*FileInfo) Reset

func (fi *FileInfo) Reset()

type FileInfoMap

type FileInfoMap map[string]*FileInfo

FileInfoMap 文件相对路径 文件信息

func AcquireFileInfoMap

func AcquireFileInfoMap() FileInfoMap

func (FileInfoMap) Equal

func (m FileInfoMap) Equal(fim FileInfoMap) bool

Equal 检测两个FileInfoMap是否相等

func (FileInfoMap) FileEqual

func (m FileInfoMap) FileEqual(fim FileInfoMap) bool

FileEqual 仅检测两个FileInfoMap的文件是否相等

func (FileInfoMap) GetIntegrity

func (m FileInfoMap) GetIntegrity() Integrity

GetIntegrity 生成这个FileInfoMap唯一的Integrity

func (FileInfoMap) Reset

func (m FileInfoMap) Reset()

type FileStore

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

func NewFileStore

func NewFileStore(cfg FileStoreConfig, ignoreFunc ...IgnoreFunc) (*FileStore, error)

NewFileStore 初始化文件存储

func (FileStore) AddDir

func (s FileStore) AddDir(absPath string) (FileInfoMap, error)

AddDir 添加目录到全局文件存储

func (FileStore) BuildDir

func (s FileStore) BuildDir(fim FileInfoMap, pkgDir string) error

BuildDir 通过FileInfoMap构建包目录在工作区构建目录下

func (FileStore) DirIsExist

func (s FileStore) DirIsExist(pkgDir string) (bool, error)

DirIsExist 检测pkgDir存在

func (FileStore) GetDirPath

func (s FileStore) GetDirPath(pkgDir string) (string, error)

GetDirPath 获取pkgDir的理论绝对路径

func (FileStore) GetMetadataPath

func (s FileStore) GetMetadataPath(pkgDir string) (string, error)

GetMetadataPath 获取metadata的理论绝对路径

func (s FileStore) Link(pkgDir, targetAbsPath string) error

Link 链接包目录到目标目录

func (FileStore) NewFileInfoMapFromDir

func (s FileStore) NewFileInfoMapFromDir(absPath string) (FileInfoMap, error)

NewFileInfoMapFromDir 仅从文件夹生成FileInfoMap

func (FileStore) VerifyDir

func (s FileStore) VerifyDir(fim FileInfoMap, absPath string) (bool, error)

VerifyDir 验证文件目录

type FileStoreConfig

type FileStoreConfig struct {
	//工作根目录
	Root string
	//元数据目录(在根目录下的相对目录)
	Metadata string
	//构建目录(在根目录下的相对目录)
	Build string
	//存储目录(在根目录下的相对目录)
	Store string
	//桶数量指数,16的指数次方
	BucketCountIndexNumber int
	//桶分配方式 hashStrMod,hashStrPrefix
	BucketAllocationMethod string
	//hash算法 建议sha512
	BucketHashType string
}

type IgnoreFunc

type IgnoreFunc func(relPath string, info os.FileInfo) bool

IgnoreFunc 忽略文件的规则 返回真为忽略

type Integrity

type Integrity string

func NewIntegrity

func NewIntegrity(integrityType string, data []byte) Integrity

NewIntegrity 新建Integrity实例

func (Integrity) GetRawHashString

func (it Integrity) GetRawHashString() (string, error)

GetRawHashString 获取原始hash字符串值 hash to string

func (Integrity) GetRawHashStringAndMod

func (it Integrity) GetRawHashStringAndMod(i uint64) (string, string, error)

func (Integrity) GetRawHashStringAndMod256

func (it Integrity) GetRawHashStringAndMod256() (string, string, error)

func (Integrity) GetRawHashStringAndModFast

func (it Integrity) GetRawHashStringAndModFast(i uint64) (string, string, error)

GetRawHashStringAndModFast 获取原始hash字符串并且快速取模(i为16的n次方)

func (Integrity) GetRawHashValue

func (it Integrity) GetRawHashValue() ([]byte, error)

GetRawHashValue 获取原始hash值

func (Integrity) GetType

func (it Integrity) GetType() string

GetType 获取hash类型

func (Integrity) GetValue

func (it Integrity) GetValue() string

GetValue 获取直接来自Integrity的值(hash+base64计算得到)

type Metadata

type Metadata interface {
	GetFileInfoMap() FileInfoMap
	SetFileInfoMap(fim FileInfoMap)
	Fetch.EasyJsonSerialization
}

Jump to

Keyboard shortcuts

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