Documentation
¶
Index ¶
- type Age
- type DataStore
- type Directory
- type DirectoryManager
- func (dm *DirectoryManager) Add(path string) error
- func (dm *DirectoryManager) AddAndSave(path string) error
- func (dm *DirectoryManager) AddUpdate(dir string) error
- func (dm *DirectoryManager) All() ([]*Directory, error)
- func (dm *DirectoryManager) Decode(data *[]byte) error
- func (dm *DirectoryManager) Dedup() error
- func (dm *DirectoryManager) DeleteTestStore() error
- func (dm *DirectoryManager) DetermineFilthy() error
- func (dm *DirectoryManager) Encode(entries []*Directory) ([]byte, error)
- func (dm *DirectoryManager) Get(path string) (*Directory, error)
- func (dm *DirectoryManager) Open(filePath string) (*[]byte, error)
- func (dm *DirectoryManager) QueryDummyData()
- func (dm *DirectoryManager) Remove(path string) error
- func (dm *DirectoryManager) RemoveIDX(idx int) error
- func (dm *DirectoryManager) Save() error
- func (dm *DirectoryManager) SortByDirectory() error
- func (dm *DirectoryManager) SwapRemove(path string) error
- func (dm *DirectoryManager) SwapRemoveIDX(idx int) error
- type Score
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DataStore ¶
type DataStore interface {
Open(filePath string) (*[]byte, error)
Decode(data *[]byte) error
Encode(entries []*Directory) ([]byte, error)
Add(path string) error // Adds to memory only
AddAndSave(path string) error // Adds and persists
Get(path string) (*Directory, error)
All() ([]*Directory, error)
Save() error
Dedup() error
SortByDirectory() error
AddUpdate(dir string) error
Remove(path string) error // Takes string path for consistency
DetermineFilthy() error
SwapRemoveIDX(idx int) error // Remove by index, O(1)
SwapRemove(path string) error // Remove by path, O(1) if found
}
type Directory ¶
func NewDirectory ¶
NewDirectory creates a new Directory instance with the given path, current time as LastVisit, and a default frecency score.
func (*Directory) UpdateLastVisit ¶
func (d *Directory) UpdateLastVisit()
UpdateLastVisit updates the LastVisit field of the Directory instance to the current time.
func (*Directory) UpdateScore ¶
func (d *Directory) UpdateScore()
UpdateScore updates the Score field of the Directory instance by multiplying it by 2.
type DirectoryManager ¶
type DirectoryManager struct {
Entries []*Directory
FilePath string
Dirty bool
// contains filtered or unexported fields
}
func CreateTestStore ¶
func CreateTestStore() (*DirectoryManager, error)
func NewDirectoryManager ¶
func NewDirectoryManager() (*DirectoryManager, error)
func NewDirectoryManagerWithPath ¶
func NewDirectoryManagerWithPath(filePath string) (*DirectoryManager, error)
NewDirectoryManager creates a new GobStore instance by accessing reading in data from the given filepath.
func (*DirectoryManager) Add ¶
func (dm *DirectoryManager) Add(path string) error
Add adds a new directory to the directory manager in memory only. It marks the manager as Dirty but does NOT persist changes to disk. Call Save() to persist or use AddAndSave for immediate persistence. Add adds a new directory to the directory manager in memory only. It marks the manager as Dirty but does NOT persist changes to disk. Call Save() to persist or use AddAndSave for immediate persistence.
func (*DirectoryManager) AddAndSave ¶ added in v1.1.3
func (dm *DirectoryManager) AddAndSave(path string) error
AddAndSave adds a new directory and immediately saves the directory manager to disk. This is the legacy behavior of Add prior to v0.2.0. AddAndSave adds a new directory and immediately saves the directory manager to disk.
func (*DirectoryManager) AddUpdate ¶
func (dm *DirectoryManager) AddUpdate(dir string) error
AddUpdate adds a directory to the directory manager and immediately persists it to file. This is equivalent to AddAndSave and is provided for API compatibility. AddUpdate adds a directory to the directory manager and immediately persists it to file.
func (*DirectoryManager) All ¶
func (dm *DirectoryManager) All() ([]*Directory, error)
gets all directories from the directory manager
func (*DirectoryManager) Decode ¶
func (dm *DirectoryManager) Decode(data *[]byte) error
Decode decodes the data from the byte slice into the DirectoryManager's Entries field.
func (*DirectoryManager) Dedup ¶
func (dm *DirectoryManager) Dedup() error
Dedup removes duplicate directories from the directory manager
func (*DirectoryManager) DeleteTestStore ¶
func (dm *DirectoryManager) DeleteTestStore() error
func (*DirectoryManager) DetermineFilthy ¶
func (dm *DirectoryManager) DetermineFilthy() error
DetermineFilthy checks if the directory manager is dirty
func (*DirectoryManager) Encode ¶
func (dm *DirectoryManager) Encode(entries []*Directory) ([]byte, error)
Encode encodes the DirectoryManager's Entries field into a byte slice.
func (*DirectoryManager) Get ¶
func (dm *DirectoryManager) Get(path string) (*Directory, error)
gets a directory from the directory manager
func (*DirectoryManager) QueryDummyData ¶
func (dm *DirectoryManager) QueryDummyData()
add dummy data to the store
func (*DirectoryManager) Remove ¶
func (dm *DirectoryManager) Remove(path string) error
Remove removes a directory from the directory manager Remove searches for a directory by path and removes it if found. Persists changes immediately.
func (*DirectoryManager) RemoveIDX ¶
func (dm *DirectoryManager) RemoveIDX(idx int) error
RemoveIDX removes an entry by index. Assumes lock is held by caller if needed and caller handles Dirty status and saving.
func (*DirectoryManager) Save ¶
func (dm *DirectoryManager) Save() error
saves the directory manager to a file
func (*DirectoryManager) SortByDirectory ¶
func (dm *DirectoryManager) SortByDirectory() error
SortByDirectory sorts the directories in the directory manager by their path
func (*DirectoryManager) SwapRemove ¶
func (dm *DirectoryManager) SwapRemove(path string) error
SwapRemove searches for a directory by path, then uses SwapRemoveIDX for O(1) removal if found. Persists changes immediately.
func (*DirectoryManager) SwapRemoveIDX ¶
func (dm *DirectoryManager) SwapRemoveIDX(idx int) error
SwapRemove removes a directory from the directory manager and updates the file useful because it makes removal 0(1) instead of O(n) SwapRemoveIDX removes a directory by index using O(1) swap and persists changes.