Documentation
¶
Index ¶
- Constants
- func CollectTopFiles(dir fs.Item, count int) fs.Files
- type BaseAnalyzer
- func (a *BaseAnalyzer) Cancel()
- func (a *BaseAnalyzer) GetCurrentDir() fs.Item
- func (a *BaseAnalyzer) GetDone() common.SignalGroup
- func (a *BaseAnalyzer) GetProgress() common.CurrentProgress
- func (a *BaseAnalyzer) Init()
- func (a *BaseAnalyzer) IsCancelled() bool
- func (a *BaseAnalyzer) ResetProgress()
- func (a *BaseAnalyzer) SetArchiveBrowsing(v bool)
- func (a *BaseAnalyzer) SetFileTypeFilter(filter common.ShouldFileBeIgnored)
- func (a *BaseAnalyzer) SetFollowSymlinks(v bool)
- func (a *BaseAnalyzer) SetShowAnnexedSize(v bool)
- func (a *BaseAnalyzer) SetTimeFilter(matchesTimeFilterFn common.TimeFilter)
- func (a *BaseAnalyzer) UpdateProgress()
- type Dir
- func (f *Dir) AddFile(item fs.Item)
- func (f *Dir) EncodeJSON(writer io.Writer, topLevel bool, attributes fs.JSONAttributes) error
- func (f *Dir) GetFiles(sortBy fs.SortBy, order fs.SortOrder) iter.Seq[fs.Item]
- func (f *Dir) GetFilesLocked(sortBy fs.SortBy, order fs.SortOrder) iter.Seq[fs.Item]
- func (f *Dir) GetFlag() rune
- func (f *Dir) GetItemCount() int64
- func (f *Dir) GetItemStats(linkedItems fs.HardLinkedItems, filteringFiles bool) (itemCount, size, usage int64)
- func (f *Dir) GetMtime() time.Time
- func (f *Dir) GetPath() string
- func (f *Dir) GetSize() int64
- func (f *Dir) GetType() string
- func (f *Dir) GetUsage() int64
- func (f *Dir) HasEmptyDirPlaceholderStats() bool
- func (f *Dir) IsDir() bool
- func (f *Dir) RLock() func()
- func (f *Dir) RemoveFile(item fs.Item)
- func (f *Dir) RemoveFileByName(name string)
- func (f *Dir) SetFlag(flag rune)
- func (f *Dir) SetStatsFromJSON()
- func (f *Dir) UpdateStats(linkedItems fs.HardLinkedItems)
- func (f *Dir) UpdateStatsWithFileFiltering(linkedItems fs.HardLinkedItems)
- type File
- func (f *File) AddFile(item fs.Item)
- func (f *File) EncodeJSON(writer io.Writer, _ bool, attributes fs.JSONAttributes) error
- func (f *File) GetFiles(sortBy fs.SortBy, order fs.SortOrder) iter.Seq[fs.Item]
- func (f *File) GetFilesLocked(sortBy fs.SortBy, order fs.SortOrder) iter.Seq[fs.Item]
- func (f *File) GetFlag() rune
- func (f *File) GetItemCount() int64
- func (f *File) GetItemStats(linkedItems fs.HardLinkedItems, filteringFiles bool) (itemCount, size, usage int64)
- func (f *File) GetMtime() time.Time
- func (f *File) GetMultiLinkedInode() uint64
- func (f *File) GetName() string
- func (f *File) GetParent() fs.Item
- func (f *File) GetPath() string
- func (f *File) GetSize() int64
- func (f *File) GetSymlinkTarget() string
- func (f *File) GetType() string
- func (f *File) GetUsage() int64
- func (f *File) IsDir() bool
- func (f *File) RLock() func()
- func (f *File) RemoveFile(item fs.Item)
- func (f *File) RemoveFileByName(name string)
- func (f *File) SetParent(parent fs.Item)
- func (f *File) UpdateStats(linkedItems fs.HardLinkedItems)
- func (f *File) UpdateStatsWithFileFiltering(linkedItems fs.HardLinkedItems)
- type ParallelAnalyzer
- type ParallelStableOrderAnalyzer
- type ParentDir
- func (p *ParentDir) AddFile(fs.Item)
- func (p *ParentDir) EncodeJSON(io.Writer, bool, fs.JSONAttributes) error
- func (p *ParentDir) GetFiles(fs.SortBy, fs.SortOrder) iter.Seq[fs.Item]
- func (p *ParentDir) GetFilesLocked(fs.SortBy, fs.SortOrder) iter.Seq[fs.Item]
- func (p *ParentDir) GetFlag() rune
- func (p *ParentDir) GetItemCount() int64
- func (p *ParentDir) GetItemStats(linkedItems fs.HardLinkedItems, filteringFiles bool) (itemCount, size, usage int64)
- func (p *ParentDir) GetMtime() time.Time
- func (p *ParentDir) GetMultiLinkedInode() uint64
- func (p *ParentDir) GetName() string
- func (p *ParentDir) GetParent() fs.Item
- func (p *ParentDir) GetPath() string
- func (p *ParentDir) GetSize() int64
- func (p *ParentDir) GetType() string
- func (p *ParentDir) GetUsage() int64
- func (p *ParentDir) IsDir() bool
- func (p *ParentDir) RLock() func()
- func (p *ParentDir) RemoveFile(item fs.Item)
- func (p *ParentDir) RemoveFileByName(name string)
- func (p *ParentDir) SetParent(fs.Item)
- func (p *ParentDir) UpdateStats(linkedItems fs.HardLinkedItems)
- func (p *ParentDir) UpdateStatsWithFileFiltering(linkedItems fs.HardLinkedItems)
- type SequentialAnalyzer
- type SimpleDir
- func (d *SimpleDir) AddFile(fs.Item)
- func (d *SimpleDir) EncodeJSON(io.Writer, bool, fs.JSONAttributes) error
- func (d *SimpleDir) GetFiles(sortBy fs.SortBy, order fs.SortOrder) iter.Seq[fs.Item]
- func (d *SimpleDir) GetFilesLocked(fs.SortBy, fs.SortOrder) iter.Seq[fs.Item]
- func (d *SimpleDir) GetFlag() rune
- func (d *SimpleDir) GetItemCount() int64
- func (d *SimpleDir) GetItemStats(linkedItems fs.HardLinkedItems, filteringFiles bool) (itemCount, size, usage int64)
- func (d *SimpleDir) GetMtime() time.Time
- func (d *SimpleDir) GetMultiLinkedInode() uint64
- func (d *SimpleDir) GetName() string
- func (d *SimpleDir) GetParent() fs.Item
- func (d *SimpleDir) GetPath() string
- func (d *SimpleDir) GetSize() int64
- func (d *SimpleDir) GetType() string
- func (d *SimpleDir) GetUsage() int64
- func (d *SimpleDir) IsDir() bool
- func (d *SimpleDir) RLock() func()
- func (d *SimpleDir) RemoveFile(fs.Item)
- func (d *SimpleDir) RemoveFileByName(name string)
- func (d *SimpleDir) SetParent(parent fs.Item)
- func (d *SimpleDir) UpdateStats(linkedItems fs.HardLinkedItems)
- func (d *SimpleDir) UpdateStatsWithFileFiltering(linkedItems fs.HardLinkedItems)
- type SimpleFile
- type SqliteAnalyzer
- type SqliteItem
- func (i *SqliteItem) AddFile(item fs.Item)
- func (i *SqliteItem) EncodeJSON(writer io.Writer, topLevel bool, attributes fs.JSONAttributes) error
- func (i *SqliteItem) GetFiles(sortBy fs.SortBy, order fs.SortOrder) iter.Seq[fs.Item]
- func (i *SqliteItem) GetFilesLocked(sortBy fs.SortBy, order fs.SortOrder) iter.Seq[fs.Item]
- func (i *SqliteItem) GetFlag() rune
- func (i *SqliteItem) GetItemCount() int64
- func (i *SqliteItem) GetItemStats(linkedItems fs.HardLinkedItems, filteringFiles bool) (itemCount, size, usage int64)
- func (i *SqliteItem) GetMtime() time.Time
- func (i *SqliteItem) GetMultiLinkedInode() uint64
- func (i *SqliteItem) GetName() string
- func (i *SqliteItem) GetParent() fs.Item
- func (i *SqliteItem) GetParentLocked() *SqliteItem
- func (i *SqliteItem) GetPath() string
- func (i *SqliteItem) GetSize() int64
- func (i *SqliteItem) GetType() string
- func (i *SqliteItem) GetUsage() int64
- func (i *SqliteItem) IsDir() bool
- func (i *SqliteItem) RLock() func()
- func (i *SqliteItem) RemoveFile(item fs.Item)
- func (i *SqliteItem) RemoveFileByName(name string)
- func (i *SqliteItem) SetParent(parent fs.Item)
- func (i *SqliteItem) UpdateStats(linkedItems fs.HardLinkedItems)
- func (i *SqliteItem) UpdateStatsWithFileFiltering(linkedItems fs.HardLinkedItems)
- type SqliteStorage
- func (s *SqliteStorage) BeginBulkInsert() error
- func (s *SqliteStorage) ClearItems() error
- func (s *SqliteStorage) Close() error
- func (s *SqliteStorage) EndBulkInsert() error
- func (s *SqliteStorage) GetChildByName(parentID int64, name string) (*SqliteItem, error)
- func (s *SqliteStorage) GetChildren(parentID int64) ([]*SqliteItem, error)
- func (s *SqliteStorage) GetItemByID(id int64) (*SqliteItem, error)
- func (s *SqliteStorage) GetMetadata(key string) (string, error)
- func (s *SqliteStorage) GetRootItem() (*SqliteItem, error)
- func (s *SqliteStorage) HasData() bool
- func (s *SqliteStorage) HasInode(mli uint64) bool
- func (s *SqliteStorage) InsertItem(parentID *int64, name string, isDir bool, size, usage int64, mtime time.Time, ...) (int64, error)
- func (s *SqliteStorage) RemoveItemAndUpdateStats(id, size, usage, itemCount int64) error
- func (s *SqliteStorage) SetMetadata(key, value string) error
- func (s *SqliteStorage) UpdateItem(id, size, usage, itemCount int64, flag rune) error
- type Storage
- type StoredAnalyzer
- type StoredDir
- func (f *StoredDir) GetFiles(sortBy fs.SortBy, order fs.SortOrder) iter.Seq[fs.Item]
- func (f *StoredDir) GetItemStats(linkedItems fs.HardLinkedItems, filteringFiles bool) (itemCount, size, usage int64)
- func (f *StoredDir) GetParent() fs.Item
- func (f *StoredDir) RemoveFile(item fs.Item)
- func (f *StoredDir) RemoveFileByName(name string)
- func (f *StoredDir) UpdateStats(linkedItems fs.HardLinkedItems)
- func (f *StoredDir) UpdateStatsWithFileFiltering(linkedItems fs.HardLinkedItems)
- type TarDir
- type TarFile
- type TopDir
- type TopDirAnalyzer
- type TopList
- type WaitGroup
- type ZipDir
- type ZipFile
Constants ¶
const EmptyDirSize int64 = 512
EmptyDirSize is the apparent size gdu assigns to a directory that has no counted children. It is a fixed sentinel (not the real filesystem block size) written by updateStats, SimpleDir.UpdateStats and the parallel top-dir analyzer, and recognised again on import. Keep every producer and consumer of this value referencing this constant so they can never drift apart.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type BaseAnalyzer ¶
type BaseAnalyzer struct {
// contains filtered or unexported fields
}
BaseAnalyzer provides common logic for all analyzers
func (*BaseAnalyzer) Cancel ¶ added in v0.3.0
func (a *BaseAnalyzer) Cancel()
Cancel stops scheduling new scan work. In-flight filesystem operations are allowed to finish so the caller can safely use the partial directory tree.
func (*BaseAnalyzer) GetCurrentDir ¶ added in v0.3.0
func (a *BaseAnalyzer) GetCurrentDir() fs.Item
GetCurrentDir returns an independent snapshot of the directory tree built so far, or nil if no analysis has started yet. Callers may aggregate or navigate the snapshot without mutating the live scan state.
func (*BaseAnalyzer) GetDone ¶
func (a *BaseAnalyzer) GetDone() common.SignalGroup
GetDone returns channel for checking when analysis is done
func (*BaseAnalyzer) GetProgress ¶
func (a *BaseAnalyzer) GetProgress() common.CurrentProgress
func (*BaseAnalyzer) IsCancelled ¶ added in v0.3.0
func (a *BaseAnalyzer) IsCancelled() bool
IsCancelled reports whether the current scan has been cancelled.
func (*BaseAnalyzer) ResetProgress ¶
func (a *BaseAnalyzer) ResetProgress()
ResetProgress prepares the analyzer for a new scan. Call it only after the previous scan has completed and before exposing the new scan to cancellation.
func (*BaseAnalyzer) SetArchiveBrowsing ¶
func (a *BaseAnalyzer) SetArchiveBrowsing(v bool)
SetArchiveBrowsing sets whether browsing of zip/jar/tar archives is enabled
func (*BaseAnalyzer) SetFileTypeFilter ¶
func (a *BaseAnalyzer) SetFileTypeFilter(filter common.ShouldFileBeIgnored)
SetFileTypeFilter sets the file type filter function
func (*BaseAnalyzer) SetFollowSymlinks ¶
func (a *BaseAnalyzer) SetFollowSymlinks(v bool)
SetFollowSymlinks sets whether symlink to files should be followed
func (*BaseAnalyzer) SetShowAnnexedSize ¶
func (a *BaseAnalyzer) SetShowAnnexedSize(v bool)
SetShowAnnexedSize sets whether to use annexed size of git-annex files
func (*BaseAnalyzer) SetTimeFilter ¶
func (a *BaseAnalyzer) SetTimeFilter(matchesTimeFilterFn common.TimeFilter)
SetTimeFilter sets the time filter function for file inclusion
func (*BaseAnalyzer) UpdateProgress ¶
func (a *BaseAnalyzer) UpdateProgress()
UpdateProgress updates progress
type Dir ¶
type Dir struct {
*File
BasePath string
Files fs.Files
ItemCount int64
// contains filtered or unexported fields
}
Dir struct
func (*Dir) EncodeJSON ¶
EncodeJSON writes JSON representation of dir
func (*Dir) GetFilesLocked ¶
GetFilesLocked returns all files in directory as a sorted iterator It is safe to call this function from multiple goroutines
func (*Dir) GetItemCount ¶
GetItemCount returns number of files in dir
func (*Dir) GetItemStats ¶
func (f *Dir) GetItemStats(linkedItems fs.HardLinkedItems, filteringFiles bool) (itemCount, size, usage int64)
GetItemStats returns item count, apparent usage and real usage of this dir
func (*Dir) HasEmptyDirPlaceholderStats ¶ added in v0.3.0
HasEmptyDirPlaceholderStats reports whether this directory's stats are indistinguishable from the placeholder updateStats produces for a directory with no counted children (see EmptyDirSize). Such stats carry no information worth pinning from an import: recomputation reproduces exactly the same values, so callers should let updateStats run rather than preserving them.
The items == 1 check is load-bearing: a depth-truncated directory that held real content always exports with ItemCount >= 2, so it can never be mistaken for a placeholder and its stats are always preserved.
func (*Dir) RemoveFile ¶
RemoveFile removes item from dir, updates size and item count
func (*Dir) RemoveFileByName ¶
RemoveFileByName removes item by name from dir
func (*Dir) SetFlag ¶ added in v0.3.0
SetFlag updates the directory flag while preserving snapshot consistency.
func (*Dir) SetStatsFromJSON ¶ added in v0.3.0
func (f *Dir) SetStatsFromJSON()
SetStatsFromJSON marks directory statistics decoded from an export as authoritative.
func (*Dir) UpdateStats ¶
func (f *Dir) UpdateStats(linkedItems fs.HardLinkedItems)
func (*Dir) UpdateStatsWithFileFiltering ¶ added in v0.3.0
func (f *Dir) UpdateStatsWithFileFiltering(linkedItems fs.HardLinkedItems)
type File ¶
type File struct {
Mtime time.Time
Parent fs.Item
Name string
Symlink string
Size int64
Usage int64
Mli uint64
Flag rune
}
File struct
func CreateFileItem ¶ added in v0.3.0
CreateFileItem creates a File from an os.FileInfo with correct platform-specific attributes
func (*File) EncodeJSON ¶
EncodeJSON writes JSON representation of file
func (*File) GetFilesLocked ¶
GetFilesLocked returns all files in directory
func (*File) GetItemStats ¶
func (f *File) GetItemStats(linkedItems fs.HardLinkedItems, filteringFiles bool) (itemCount, size, usage int64)
GetItemStats returns 1 as count of items, apparent usage and real usage of this file
func (*File) GetMultiLinkedInode ¶
GetMultiLinkedInode returns inode number of multilinked file
func (*File) GetSymlinkTarget ¶ added in v0.3.0
GetSymlinkTarget returns the target of a symlink, or empty string
func (*File) RemoveFileByName ¶
RemoveFileByName panics on file
func (*File) UpdateStats ¶
func (f *File) UpdateStats(linkedItems fs.HardLinkedItems)
UpdateStats does nothing on file
func (*File) UpdateStatsWithFileFiltering ¶ added in v0.3.0
func (f *File) UpdateStatsWithFileFiltering(linkedItems fs.HardLinkedItems)
type ParallelAnalyzer ¶
type ParallelAnalyzer struct {
BaseAnalyzer
}
ParallelAnalyzer implements Analyzer
func (*ParallelAnalyzer) AnalyzeDir ¶
func (a *ParallelAnalyzer) AnalyzeDir( path string, ignore common.ShouldDirBeIgnored, fileTypeFilter common.ShouldFileBeIgnored, ) fs.Item
AnalyzeDir analyzes given path
type ParallelStableOrderAnalyzer ¶
type ParallelStableOrderAnalyzer struct {
BaseAnalyzer
}
ParallelStableOrderAnalyzer implements Analyzer
func CreateStableOrderAnalyzer ¶
func CreateStableOrderAnalyzer() *ParallelStableOrderAnalyzer
CreateStableOrderAnalyzer returns parallel Analyzer which keeps stable order of files
func (*ParallelStableOrderAnalyzer) AnalyzeDir ¶
func (a *ParallelStableOrderAnalyzer) AnalyzeDir( path string, ignore common.ShouldDirBeIgnored, fileTypeFilter common.ShouldFileBeIgnored, ) fs.Item
AnalyzeDir analyzes given path
type ParentDir ¶
type ParentDir struct {
Path string
}
ParentDir represents parent directory of single file It is used to get path to parent directory of a file
func (*ParentDir) EncodeJSON ¶
func (*ParentDir) GetFilesLocked ¶
func (*ParentDir) GetItemCount ¶
func (*ParentDir) GetItemStats ¶
func (p *ParentDir) GetItemStats( linkedItems fs.HardLinkedItems, filteringFiles bool, ) (itemCount, size, usage int64)
func (*ParentDir) GetMultiLinkedInode ¶
func (*ParentDir) RemoveFile ¶
func (*ParentDir) RemoveFileByName ¶
func (*ParentDir) UpdateStats ¶
func (p *ParentDir) UpdateStats(linkedItems fs.HardLinkedItems)
func (*ParentDir) UpdateStatsWithFileFiltering ¶ added in v0.3.0
func (p *ParentDir) UpdateStatsWithFileFiltering(linkedItems fs.HardLinkedItems)
type SequentialAnalyzer ¶
type SequentialAnalyzer struct {
BaseAnalyzer
}
SequentialAnalyzer implements Analyzer
func CreateSeqAnalyzer ¶
func CreateSeqAnalyzer() *SequentialAnalyzer
CreateSeqAnalyzer returns Analyzer
func (*SequentialAnalyzer) AnalyzeDir ¶
func (a *SequentialAnalyzer) AnalyzeDir( path string, ignore common.ShouldDirBeIgnored, fileTypeFilter common.ShouldFileBeIgnored, ) fs.Item
AnalyzeDir analyzes given path
type SimpleDir ¶
type SimpleDir struct {
SimpleFile
Files []SimpleFile
BasePath string
}
func (*SimpleDir) EncodeJSON ¶
func (*SimpleDir) GetFilesLocked ¶
func (*SimpleDir) GetItemCount ¶
func (*SimpleDir) GetItemStats ¶
func (d *SimpleDir) GetItemStats(linkedItems fs.HardLinkedItems, filteringFiles bool) (itemCount, size, usage int64)
func (*SimpleDir) GetMultiLinkedInode ¶
func (*SimpleDir) RemoveFile ¶
func (*SimpleDir) RemoveFileByName ¶
func (*SimpleDir) UpdateStats ¶
func (d *SimpleDir) UpdateStats(linkedItems fs.HardLinkedItems)
func (*SimpleDir) UpdateStatsWithFileFiltering ¶ added in v0.3.0
func (d *SimpleDir) UpdateStatsWithFileFiltering(linkedItems fs.HardLinkedItems)
type SimpleFile ¶
type SqliteAnalyzer ¶
type SqliteAnalyzer struct {
BaseAnalyzer
// contains filtered or unexported fields
}
SqliteAnalyzer implements Analyzer using SQLite storage
func CreateSqliteAnalyzer ¶
func CreateSqliteAnalyzer(dbPath string) (*SqliteAnalyzer, error)
CreateSqliteAnalyzer creates a new SQLite analyzer
func (*SqliteAnalyzer) AnalyzeDir ¶
func (a *SqliteAnalyzer) AnalyzeDir( path string, ignore common.ShouldDirBeIgnored, fileTypeFilter common.ShouldFileBeIgnored, ) fs.Item
AnalyzeDir analyzes the given path and stores results in SQLite. If the database already contains data, it loads from the database instead of re-scanning.
type SqliteItem ¶
type SqliteItem struct {
// contains filtered or unexported fields
}
SqliteItem represents a file or directory stored in SQLite
func (*SqliteItem) AddFile ¶
func (i *SqliteItem) AddFile(item fs.Item)
AddFile adds a child file (no-op for SQLite items - children are in DB)
func (*SqliteItem) EncodeJSON ¶
func (i *SqliteItem) EncodeJSON(writer io.Writer, topLevel bool, attributes fs.JSONAttributes) error
EncodeJSON encodes the item to JSON
func (*SqliteItem) GetFilesLocked ¶
GetFilesLocked returns children with locking
func (*SqliteItem) GetFlag ¶
func (i *SqliteItem) GetFlag() rune
GetFlag returns the flag of the item
func (*SqliteItem) GetItemCount ¶
func (i *SqliteItem) GetItemCount() int64
GetItemCount returns the item count
func (*SqliteItem) GetItemStats ¶
func (i *SqliteItem) GetItemStats(linkedItems fs.HardLinkedItems, filteringFiles bool) (itemCount, size, usage int64)
GetItemStats returns item statistics - hard links already handled during scan
func (*SqliteItem) GetMtime ¶
func (i *SqliteItem) GetMtime() time.Time
GetMtime returns the modification time
func (*SqliteItem) GetMultiLinkedInode ¶
func (i *SqliteItem) GetMultiLinkedInode() uint64
GetMultiLinkedInode returns the multi-linked inode number
func (*SqliteItem) GetName ¶
func (i *SqliteItem) GetName() string
GetName returns the name of the item
func (*SqliteItem) GetParent ¶
func (i *SqliteItem) GetParent() fs.Item
GetParent returns the parent item
func (*SqliteItem) GetParentLocked ¶
func (i *SqliteItem) GetParentLocked() *SqliteItem
GetParentLocked returns the in-memory parent without hitting the database. Used inside RemoveFile where storage.m is already write-locked.
func (*SqliteItem) GetPath ¶
func (i *SqliteItem) GetPath() string
GetPath returns the full path of the item
func (*SqliteItem) GetType ¶
func (i *SqliteItem) GetType() string
GetType returns the type of the item
func (*SqliteItem) IsDir ¶
func (i *SqliteItem) IsDir() bool
IsDir returns true if the item is a directory
func (*SqliteItem) RLock ¶
func (i *SqliteItem) RLock() func()
RLock returns a no-op unlock function
func (*SqliteItem) RemoveFile ¶
func (i *SqliteItem) RemoveFile(item fs.Item)
RemoveFile removes a child file, updating both in-memory stats and the database in one pass.
func (*SqliteItem) RemoveFileByName ¶
func (i *SqliteItem) RemoveFileByName(name string)
RemoveFileByName removes a child by name
func (*SqliteItem) SetParent ¶
func (i *SqliteItem) SetParent(parent fs.Item)
SetParent sets the parent item
func (*SqliteItem) UpdateStats ¶
func (i *SqliteItem) UpdateStats(linkedItems fs.HardLinkedItems)
UpdateStats is a no-op for SqliteItem - hard links are handled during scan
func (*SqliteItem) UpdateStatsWithFileFiltering ¶ added in v0.3.0
func (i *SqliteItem) UpdateStatsWithFileFiltering(linkedItems fs.HardLinkedItems)
type SqliteStorage ¶
type SqliteStorage struct {
// contains filtered or unexported fields
}
SqliteStorage represents SQLite database storage
func NewSqliteStorage ¶
func NewSqliteStorage(dbPath string) (*SqliteStorage, error)
NewSqliteStorage creates a new SQLite storage and initializes the schema
func (*SqliteStorage) BeginBulkInsert ¶
func (s *SqliteStorage) BeginBulkInsert() error
BeginBulkInsert starts a transaction and prepares statements for bulk insertion
func (*SqliteStorage) ClearItems ¶
func (s *SqliteStorage) ClearItems() error
ClearItems removes all items from the database
func (*SqliteStorage) Close ¶
func (s *SqliteStorage) Close() error
Close closes the database connection
func (*SqliteStorage) EndBulkInsert ¶
func (s *SqliteStorage) EndBulkInsert() error
EndBulkInsert commits the transaction and closes prepared statements
func (*SqliteStorage) GetChildByName ¶
func (s *SqliteStorage) GetChildByName(parentID int64, name string) (*SqliteItem, error)
GetChildByName returns a child item by its name and parent ID
func (*SqliteStorage) GetChildren ¶
func (s *SqliteStorage) GetChildren(parentID int64) ([]*SqliteItem, error)
GetChildren returns all children of a given parent ID
func (*SqliteStorage) GetItemByID ¶
func (s *SqliteStorage) GetItemByID(id int64) (*SqliteItem, error)
GetItemByID returns an item by its ID
func (*SqliteStorage) GetMetadata ¶
func (s *SqliteStorage) GetMetadata(key string) (string, error)
GetMetadata retrieves a metadata value by key
func (*SqliteStorage) GetRootItem ¶
func (s *SqliteStorage) GetRootItem() (*SqliteItem, error)
GetRootItem returns the root item (item with no parent)
func (*SqliteStorage) HasData ¶
func (s *SqliteStorage) HasData() bool
HasData returns true if the database contains analysis data
func (*SqliteStorage) HasInode ¶
func (s *SqliteStorage) HasInode(mli uint64) bool
HasInode returns true if a file with the given inode already exists in the database
func (*SqliteStorage) InsertItem ¶
func (s *SqliteStorage) InsertItem( parentID *int64, name string, isDir bool, size, usage int64, mtime time.Time, itemCount int64, mli uint64, flag rune, ) (int64, error)
InsertItem inserts a file/directory item into the database
func (*SqliteStorage) RemoveItemAndUpdateStats ¶
func (s *SqliteStorage) RemoveItemAndUpdateStats(id, size, usage, itemCount int64) error
RemoveItemAndUpdateStats removes an item and updates all its ancestors' stats in the database
func (*SqliteStorage) SetMetadata ¶
func (s *SqliteStorage) SetMetadata(key, value string) error
SetMetadata stores a metadata key-value pair
func (*SqliteStorage) UpdateItem ¶
func (s *SqliteStorage) UpdateItem(id, size, usage, itemCount int64, flag rune) error
UpdateItem updates an existing item's stats
type Storage ¶
type Storage struct {
// contains filtered or unexported fields
}
Storage represents a badger storage
var DefaultStorage *Storage
DefaultStorage is a default instance of badger storage
func NewStorage ¶
NewStorage returns new instance of badger storage
func (*Storage) GetDirForPath ¶
GetDirForPath returns Dir for given path
type StoredAnalyzer ¶
type StoredAnalyzer struct {
BaseAnalyzer
// contains filtered or unexported fields
}
StoredAnalyzer implements Analyzer
func CreateStoredAnalyzer ¶
func CreateStoredAnalyzer(storagePath string) *StoredAnalyzer
CreateStoredAnalyzer returns Analyzer
func (*StoredAnalyzer) AnalyzeDir ¶
func (a *StoredAnalyzer) AnalyzeDir( path string, ignore common.ShouldDirBeIgnored, fileTypeFilter common.ShouldFileBeIgnored, ) fs.Item
AnalyzeDir analyzes given path
type StoredDir ¶
type StoredDir struct {
*Dir
// contains filtered or unexported fields
}
StoredDir implements Dir item stored on disk
func (*StoredDir) GetFiles ¶
GetFiles returns files in directory as a sorted iterator If files are already cached, use them Otherwise load them from storage
func (*StoredDir) GetItemStats ¶
func (f *StoredDir) GetItemStats(linkedItems fs.HardLinkedItems, filteringFiles bool) (itemCount, size, usage int64)
GetItemStats returns item count, apparent usage and real usage of this dir
func (*StoredDir) RemoveFile ¶
RemoveFile removes file from stored directory It also updates size and item count of parent directories
func (*StoredDir) RemoveFileByName ¶
RemoveFileByName removes file by name from stored directory
func (*StoredDir) UpdateStats ¶
func (f *StoredDir) UpdateStats(linkedItems fs.HardLinkedItems)
UpdateStats recursively updates size and item count
func (*StoredDir) UpdateStatsWithFileFiltering ¶ added in v0.3.0
func (f *StoredDir) UpdateStatsWithFileFiltering(linkedItems fs.HardLinkedItems)
type TarDir ¶
type TarDir struct {
*Dir
// contains filtered or unexported fields
}
TarDir represents a directory structure inside a tar archive
func (*TarDir) EncodeJSON ¶
EncodeJSON encodes tar directory to JSON
type TarFile ¶
type TarFile struct {
*File
// contains filtered or unexported fields
}
TarFile represents a file inside a tar archive
func (*TarFile) EncodeJSON ¶
EncodeJSON encodes tar file to JSON
type TopDir ¶
type TopDirAnalyzer ¶
type TopDirAnalyzer struct {
BaseAnalyzer
// contains filtered or unexported fields
}
TopDirAnalyzer implements Analyzer It doesn't return the full directory structure, only the top level directory, thus is suitable only for non-interactive mode. It tries to use only stack for storing state and results.
func CreateTopDirAnalyzer ¶
func CreateTopDirAnalyzer() *TopDirAnalyzer
CreateTopDirAnalyzer returns Analyzer
func (*TopDirAnalyzer) AnalyzeDir ¶
func (a *TopDirAnalyzer) AnalyzeDir( path string, ignore common.ShouldDirBeIgnored, fileTypeFilter common.ShouldFileBeIgnored, ) fs.Item
AnalyzeDir analyzes given path
type WaitGroup ¶
type WaitGroup struct {
// contains filtered or unexported fields
}
A WaitGroup waits for a collection of goroutines to finish. In contrast to sync.WaitGroup Add method can be called from a goroutine.
func (*WaitGroup) Done ¶
func (s *WaitGroup) Done()
Done decrements the value by one, if value is 0, lock is released
type ZipDir ¶
type ZipDir struct {
*Dir
// contains filtered or unexported fields
}
ZipDir represents a directory structure inside a zip file
func (*ZipDir) EncodeJSON ¶
EncodeJSON encodes zip directory to JSON