Documentation
¶
Index ¶
- Variables
- type BoltFS
- func (fs *BoltFS) Chmod(name string, mode os.FileMode) error
- func (fs *BoltFS) Chown(name string, uid, gid int) error
- func (fs *BoltFS) Chtimes(name string, atime time.Time, mtime time.Time) error
- func (fs *BoltFS) Close() error
- func (fs *BoltFS) Compact() error
- func (fs *BoltFS) Create(name string) (afero.File, error)
- func (fs *BoltFS) GetThumbnail(path string) ([]byte, error)
- func (fs *BoltFS) Lchown(name string, uid, gid int) error
- func (fs *BoltFS) Mkdir(name string, perm os.FileMode) error
- func (fs *BoltFS) MkdirAll(path string, perm os.FileMode) error
- func (fs *BoltFS) Name() string
- func (fs *BoltFS) Open(name string) (afero.File, error)
- func (fs *BoltFS) OpenFile(name string, flag int, perm os.FileMode) (afero.File, error)
- func (fs *BoltFS) ReadlinkIfPossible(name string) (string, error)
- func (fs *BoltFS) Remove(name string) error
- func (fs *BoltFS) RemoveAll(path string) error
- func (fs *BoltFS) Rename(oldname, newname string) error
- func (fs *BoltFS) SaveMetadata(meta *FileMetadata) error
- func (fs *BoltFS) Stat(name string) (os.FileInfo, error)
- func (fs *BoltFS) Stats() (map[string]any, error)
- func (fs *BoltFS) StoreThumbnail(originalPath string, thumbnailData []byte, contentType string) error
- func (fs *BoltFS) SymlinkIfPossible(oldname, newname string) error
- type BoltFile
- func (f *BoltFile) Close() error
- func (f *BoltFile) Name() string
- func (f *BoltFile) Read(p []byte) (n int, err error)
- func (f *BoltFile) ReadAt(p []byte, off int64) (n int, err error)
- func (f *BoltFile) Readdir(count int) ([]os.FileInfo, error)
- func (f *BoltFile) Readdirnames(count int) ([]string, error)
- func (f *BoltFile) Seek(offset int64, whence int) (int64, error)
- func (f *BoltFile) Stat() (os.FileInfo, error)
- func (f *BoltFile) Sync() error
- func (f *BoltFile) Truncate(size int64) error
- func (f *BoltFile) Write(p []byte) (n int, err error)
- func (f *BoltFile) WriteAt(p []byte, off int64) (n int, err error)
- func (f *BoltFile) WriteString(s string) (int, error)
- type BoltFileInfo
- type DirEntry
- type FileMetadata
- func (m *FileMetadata) Clone() *FileMetadata
- func (m *FileMetadata) GetSize() int64
- func (m *FileMetadata) Lock()
- func (m *FileMetadata) Marshal() ([]byte, error)
- func (m *FileMetadata) RLock()
- func (m *FileMetadata) RUnlock()
- func (m *FileMetadata) SetSize(size int64)
- func (m *FileMetadata) ToFileInfo() os.FileInfo
- func (m *FileMetadata) Unlock()
- func (m *FileMetadata) Unmarshal(data []byte) error
- type IndexManager
- func (im *IndexManager) AddContentIndex(contentHash string, filePath string) error
- func (im *IndexManager) AddToDirIndex(dirPath, fileName string, isDir bool) error
- func (im *IndexManager) BatchUpdate(updates []IndexUpdate) error
- func (im *IndexManager) DeletePath(path string) error
- func (im *IndexManager) FindDuplicateFiles(contentHash string) ([]string, error)
- func (im *IndexManager) GetPath(path string) (*FileMetadata, error)
- func (im *IndexManager) GetStats() (*IndexStats, error)
- func (im *IndexManager) Initialize() error
- func (im *IndexManager) ListDir(dirPath string) ([]DirEntry, error)
- func (im *IndexManager) PathExists(path string) bool
- func (im *IndexManager) PutPath(path string, meta *FileMetadata) error
- func (im *IndexManager) RemoveContentIndex(contentHash, filePath string) error
- func (im *IndexManager) RemoveFromDirIndex(dirPath, fileName string) error
- func (im *IndexManager) SearchByPattern(pattern string) ([]string, error)
- func (im *IndexManager) SearchByPrefix(prefix string) ([]string, error)
- type IndexStats
- type IndexUpdate
- type UpdateType
Constants ¶
This section is empty.
Variables ¶
var ( ErrIsDirectory = errors.New("is a directory") ErrNotDirectory = errors.New("not a directory") )
错误定义
var (
ErrInvalidSeek = errors.New("invalid seek")
)
Functions ¶
This section is empty.
Types ¶
type BoltFS ¶
type BoltFS struct {
// contains filtered or unexported fields
}
BoltFS 基于BoltDB的文件系统,实现afero.Fs接口
func (*BoltFS) GetThumbnail ¶
GetThumbnail 获取缩略图
func (*BoltFS) ReadlinkIfPossible ¶
ReadlinkIfPossible 读取符号链接(不支持)
func (*BoltFS) SaveMetadata ¶
func (fs *BoltFS) SaveMetadata(meta *FileMetadata) error
SaveMetadata 方法,用于外部调用
func (*BoltFS) StoreThumbnail ¶
func (fs *BoltFS) StoreThumbnail(originalPath string, thumbnailData []byte, contentType string) error
StoreThumbnail 存储缩略图
func (*BoltFS) SymlinkIfPossible ¶
SymlinkIfPossible 创建符号链接(不支持)
type BoltFile ¶
type BoltFile struct {
// contains filtered or unexported fields
}
BoltFile 实现afero.File接口
func (*BoltFile) Readdirnames ¶
Readdirnames 读取目录名称
type BoltFileInfo ¶
type BoltFileInfo struct {
// contains filtered or unexported fields
}
BoltFileInfo 实现os.FileInfo接口
func (*BoltFileInfo) IsDir ¶
func (fi *BoltFileInfo) IsDir() bool
func (*BoltFileInfo) ModTime ¶
func (fi *BoltFileInfo) ModTime() time.Time
func (*BoltFileInfo) Mode ¶
func (fi *BoltFileInfo) Mode() os.FileMode
func (*BoltFileInfo) Name ¶
func (fi *BoltFileInfo) Name() string
func (*BoltFileInfo) Size ¶
func (fi *BoltFileInfo) Size() int64
func (*BoltFileInfo) Sys ¶
func (fi *BoltFileInfo) Sys() interface{}
type DirEntry ¶
type DirEntry struct {
Name string `json:"name"`
IsDir bool `json:"is_dir"`
Modified time.Time `json:"modified"`
}
DirEntry 目录条目
type FileMetadata ¶
type FileMetadata struct {
Name string `json:"name"`
Size int64 `json:"size"`
Mode uint32 `json:"mode"`
ModTime time.Time `json:"mod_time"`
AccessTime time.Time `json:"access_time"`
IsDir bool `json:"is_dir"`
ParentDir string `json:"parent_dir"`
DataKey string `json:"data_key"` // 数据在BoltDB中的key
Version int `json:"version"` // 乐观锁版本
ContentType string `json:"content_type"` // 文件类型,对缩略图有用
ThumbnailKey string `json:"thumbnail_key"` // 缩略图key(如果有)
// contains filtered or unexported fields
}
FileMetadata 文件元数据
func NewFileMetadata ¶
func NewFileMetadata(name string, isDir bool, perm os.FileMode) *FileMetadata
NewFileMetadata 创建新文件元数据
func (*FileMetadata) Clone ¶
func (m *FileMetadata) Clone() *FileMetadata
func (*FileMetadata) SetSize ¶
func (m *FileMetadata) SetSize(size int64)
func (*FileMetadata) ToFileInfo ¶
func (m *FileMetadata) ToFileInfo() os.FileInfo
ToFileInfo 转换为os.FileInfo ToFileInfo 转换为os.FileInfo
func (*FileMetadata) Unmarshal ¶
func (m *FileMetadata) Unmarshal(data []byte) error
Unmarshal 反序列化元数据
type IndexManager ¶
type IndexManager struct {
// contains filtered or unexported fields
}
IndexManager 索引管理器
func NewIndexManager ¶
func NewIndexManager(db *bolt.DB, enableCache bool) *IndexManager
NewIndexManager 创建索引管理器
func (*IndexManager) AddContentIndex ¶
func (im *IndexManager) AddContentIndex(contentHash string, filePath string) error
AddContentIndex 添加内容索引(用于文件去重)
func (*IndexManager) AddToDirIndex ¶
func (im *IndexManager) AddToDirIndex(dirPath, fileName string, isDir bool) error
AddToDirIndex 添加文件到目录索引
func (*IndexManager) BatchUpdate ¶
func (im *IndexManager) BatchUpdate(updates []IndexUpdate) error
BatchUpdate 批量更新索引
func (*IndexManager) DeletePath ¶
func (im *IndexManager) DeletePath(path string) error
DeletePath 删除路径索引
func (*IndexManager) FindDuplicateFiles ¶
func (im *IndexManager) FindDuplicateFiles(contentHash string) ([]string, error)
FindDuplicateFiles 查找重复文件
func (*IndexManager) GetPath ¶
func (im *IndexManager) GetPath(path string) (*FileMetadata, error)
GetPath 获取路径索引
func (*IndexManager) GetStats ¶
func (im *IndexManager) GetStats() (*IndexStats, error)
GetStats 获取索引统计信息
func (*IndexManager) Initialize ¶
func (im *IndexManager) Initialize() error
Initialize 初始化索引Buckets
func (*IndexManager) ListDir ¶
func (im *IndexManager) ListDir(dirPath string) ([]DirEntry, error)
ListDir 列出目录内容
func (*IndexManager) PathExists ¶
func (im *IndexManager) PathExists(path string) bool
PathExists 检查路径是否存在
func (*IndexManager) PutPath ¶
func (im *IndexManager) PutPath(path string, meta *FileMetadata) error
PutPath 添加/更新路径索引
func (*IndexManager) RemoveContentIndex ¶
func (im *IndexManager) RemoveContentIndex(contentHash, filePath string) error
RemoveContentIndex 移除内容索引
func (*IndexManager) RemoveFromDirIndex ¶
func (im *IndexManager) RemoveFromDirIndex(dirPath, fileName string) error
RemoveFromDirIndex 从目录索引移除文件
func (*IndexManager) SearchByPattern ¶
func (im *IndexManager) SearchByPattern(pattern string) ([]string, error)
SearchByPattern 模式搜索(简单通配符)
func (*IndexManager) SearchByPrefix ¶
func (im *IndexManager) SearchByPrefix(prefix string) ([]string, error)
SearchByPrefix 前缀搜索
type IndexStats ¶
type IndexStats struct {
TotalFiles int64 `json:"total_files"`
TotalDirs int64 `json:"total_dirs"`
UniqueContentHashes int64 `json:"unique_content_hashes"`
}
IndexStats 索引统计信息
type IndexUpdate ¶
type IndexUpdate struct {
Type UpdateType
Key string
Metadata *FileMetadata
DirPath string
FileName string
IsDir bool
}
IndexUpdate 索引更新操作
type UpdateType ¶
type UpdateType int
const ( UpdateTypePath UpdateType = iota UpdateTypeDirAdd UpdateTypeDirRemove )