Documentation
¶
Index ¶
- Variables
- type DownloadTrafficStat
- type LeftRightDiff
- type Log
- type MergeResult
- type Repo
- func (repo *Repo) AddTag(id, tag string) (err error)
- func (repo *Repo) Checkout(id string, context map[string]interface{}) (upserts, removes []*entity.File, err error)
- func (repo *Repo) CheckoutFilesFromCloud(files []*entity.File, context map[string]interface{}) (stat *DownloadTrafficStat, err error)
- func (repo *Repo) CreateCloudRepo(name string) (err error)
- func (repo *Repo) DiffIndex(leftIndexID, rightIndexID string) (ret *LeftRightDiff, err error)
- func (repo *Repo) DiffUpsertRemove(left, right []*entity.File) (upserts, removes []*entity.File)
- func (repo *Repo) DownloadTagIndex(tag, id string, context map[string]interface{}) (downloadFileCount, downloadChunkCount int, downloadBytes int64, err error)
- func (repo *Repo) GetCloudAvailableSize() (ret int64)
- func (repo *Repo) GetCloudRepoStat() (stat *cloud.Stat, err error)
- func (repo *Repo) GetCloudRepoTagLogs(context map[string]interface{}) (ret []*Log, err error)
- func (repo *Repo) GetCloudRepos() (repos []*cloud.Repo, size int64, err error)
- func (repo *Repo) GetFile(fileID string) (ret *entity.File, err error)
- func (repo *Repo) GetFiles(index *entity.Index) (ret []*entity.File, err error)
- func (repo *Repo) GetIndex(id string) (index *entity.Index, err error)
- func (repo *Repo) GetIndexLogs(page, pageSize int) (ret []*Log, pageCount, totalCount int, err error)
- func (repo *Repo) GetSyncCloudFiles(context map[string]interface{}) (fetchedFiles []*entity.File, err error)
- func (repo *Repo) GetTag(tag string) (id string, err error)
- func (repo *Repo) GetTagLogs() (ret []*Log, err error)
- func (repo *Repo) Index(memo string, context map[string]interface{}) (ret *entity.Index, err error)
- func (repo *Repo) Latest() (ret *entity.Index, err error)
- func (repo *Repo) OpenFile(file *entity.File) (ret []byte, err error)
- func (repo *Repo) OpenFileByID(fileID string) (ret []byte, err error)
- func (repo *Repo) PutIndex(index *entity.Index) (err error)
- func (repo *Repo) RemoveCloudRepo(name string) (err error)
- func (repo *Repo) RemoveCloudRepoTag(tag string) (err error)
- func (repo *Repo) RemoveTag(tag string) (err error)
- func (repo *Repo) Sync(context map[string]interface{}) (mergeResult *MergeResult, trafficStat *TrafficStat, err error)
- func (repo *Repo) SyncDownload(context map[string]interface{}) (mergeResult *MergeResult, trafficStat *TrafficStat, err error)
- func (repo *Repo) SyncUpload(context map[string]interface{}) (trafficStat *TrafficStat, err error)
- func (repo *Repo) UpdateLatest(id string) (err error)
- func (repo *Repo) UpdateLatestSync(id string) (err error)
- func (repo *Repo) UploadTagIndex(tag, id string, context map[string]interface{}) (uploadFileCount, uploadChunkCount int, uploadBytes int64, err error)
- type Store
- func (store *Store) AbsPath(id string) (dir, file string)
- func (store *Store) GetChunk(id string) (ret *entity.Chunk, err error)
- func (store *Store) GetFile(id string) (ret *entity.File, err error)
- func (store *Store) GetIndex(id string) (ret *entity.Index, err error)
- func (store *Store) IndexAbsPath(id string) (dir, file string)
- func (store *Store) PutChunk(chunk *entity.Chunk) (err error)
- func (store *Store) PutFile(file *entity.File) (err error)
- func (store *Store) PutIndex(index *entity.Index) (err error)
- func (store *Store) Remove(id string) (err error)
- func (store *Store) Stat(id string) (stat os.FileInfo, err error)
- type TrafficStat
- type UploadTrafficStat
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrCloudStorageSizeExceeded = errors.New("cloud storage limit size exceeded") ErrCloudBackupCountExceeded = errors.New("cloud backup count exceeded") ErrCloudGenerateConflictHistory = errors.New("generate conflict history failed") )
View Source
var ( ErrLockCloudFailed = errors.New("lock cloud repo failed") ErrCloudLocked = errors.New("cloud repo is locked") )
View Source
var ErrNotFoundIndex = errors.New("not found index")
View Source
var ErrNotFoundObject = errors.New("not found object")
View Source
var ErrRepoFatalErr = errors.New("repo fatal error")
Functions ¶
This section is empty.
Types ¶
type DownloadTrafficStat ¶
type LeftRightDiff ¶
type Log ¶
type Log struct { ID string `json:"id"` // Hash Parent string `json:"parent"` // 指向上一个索引 Memo string `json:"memo"` // 索引备注 Created int64 `json:"created"` // 索引时间 HCreated string `json:"hCreated"` // 索引时间 "2006-01-02 15:04:05" Files []*entity.File `json:"files"` // 文件列表 Count int `json:"count"` // 文件总数 Size int64 `json:"size"` // 文件总大小 HSize string `json:"hSize"` // 格式化好的文件总大小 "10.00 MB" Tag string `json:"tag"` // 索引标记名称 HTagUpdated string `json:"hTagUpdated"` // 标记时间 "2006-01-02 15:04:05" }
type MergeResult ¶
type Repo ¶
type Repo struct { DataPath string // 数据文件夹的绝对路径,如:F:\\SiYuan\\data\\ Path string // 仓库的绝对路径,如:F:\\SiYuan\\repo\\ HistoryPath string // 数据历史文件夹的绝对路径,如:F:\\SiYuan\\history\\ TempPath string // 临时文件夹的绝对路径,如:F:\\SiYuan\\temp\\ DeviceID string // 设备 ID IgnoreLines []string // 忽略配置文件内容行,是用 .gitignore 语法 // contains filtered or unexported fields }
Repo 描述了逮虾户数据仓库。
func NewRepo ¶
func NewRepo(dataPath, repoPath, historyPath, tempPath, deviceID string, aesKey []byte, ignoreLines []string, cloud cloud.Cloud) (ret *Repo, err error)
NewRepo 创建一个新的仓库。
func (*Repo) Checkout ¶
func (repo *Repo) Checkout(id string, context map[string]interface{}) (upserts, removes []*entity.File, err error)
Checkout 将仓库中的数据迁出到 repo 数据文件夹下。context 参数用于发布事件时传递调用上下文。
func (*Repo) CheckoutFilesFromCloud ¶
func (*Repo) CreateCloudRepo ¶
func (*Repo) DiffIndex ¶
func (repo *Repo) DiffIndex(leftIndexID, rightIndexID string) (ret *LeftRightDiff, err error)
DiffIndex 返回索引 left 比索引 right 新增、更新和删除的文件列表。
func (*Repo) DiffUpsertRemove ¶
DiffUpsertRemove 比较 left 多于/变动 right 的文件以及 left 少于 right 的文件。
func (*Repo) DownloadTagIndex ¶
func (*Repo) GetCloudAvailableSize ¶
func (*Repo) GetCloudRepoTagLogs ¶
func (*Repo) GetCloudRepos ¶
func (*Repo) GetIndexLogs ¶
func (*Repo) GetSyncCloudFiles ¶
func (*Repo) GetTagLogs ¶
func (*Repo) RemoveCloudRepo ¶
func (*Repo) RemoveCloudRepoTag ¶
func (*Repo) Sync ¶
func (repo *Repo) Sync(context map[string]interface{}) (mergeResult *MergeResult, trafficStat *TrafficStat, err error)
func (*Repo) SyncDownload ¶
func (repo *Repo) SyncDownload(context map[string]interface{}) (mergeResult *MergeResult, trafficStat *TrafficStat, err error)
func (*Repo) SyncUpload ¶
func (repo *Repo) SyncUpload(context map[string]interface{}) (trafficStat *TrafficStat, err error)
func (*Repo) UpdateLatest ¶
func (*Repo) UpdateLatestSync ¶
type Store ¶
type Store struct { Path string // 存储库文件夹的绝对路径,如:F:\\SiYuan\\repo\\ AesKey []byte // contains filtered or unexported fields }
Store 描述了存储库。
func (*Store) IndexAbsPath ¶
type TrafficStat ¶
type TrafficStat struct { DownloadTrafficStat UploadTrafficStat }
type UploadTrafficStat ¶
Source Files
¶
Click to show internal directories.
Click to hide internal directories.