Documentation ¶
Index ¶
- type DuplicateInfo
- type DuplicateSet
- type FileInfo
- type InfoSummary
- type Session
- func (s *Session) Add(info FileInfo) herror.Interface
- func (s *Session) AllDuplicates(path string) ([]DuplicateSet, herror.Interface)
- func (s *Session) AllDuplicatesC(path string) (<-chan DuplicateSet, herror.Interface)
- func (s *Session) AllInfos() ([]FileInfo, herror.Interface)
- func (s *Session) AllInfosC() (<-chan FileInfo, herror.Interface)
- func (s *Session) Begin() (*Session, herror.Interface)
- func (s *Session) Commit() herror.Interface
- func (s *Session) CreateIndexes() herror.Interface
- func (s *Session) InfosBySize(size int64) ([]FileInfo, herror.Interface)
- func (s *Session) Lookup(path string) (DuplicateSet, herror.Interface)
- func (s *Session) LookupAll(path string, includeHidden bool) ([]DuplicateInfo, herror.Interface)
- func (s *Session) LookupAllC(path string, includeHidden bool) (<-chan DuplicateInfo, herror.Interface)
- func (s *Session) Remove(path string) herror.Interface
- func (s *Session) RemoveDir(dir string, min, max int64) herror.Interface
- func (s *Session) Summary() (InfoSummary, herror.Interface)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DuplicateInfo ¶
type DuplicateSet ¶
type DuplicateSet []FileInfo
type InfoSummary ¶
type Session ¶
type Session struct {
// contains filtered or unexported fields
}
A database session, or a transaction.
This is a sort of weird implementation, but it makes the interface/implementation convenient. The same type exposes a bunch of methods that operate on the database, and the object and methods are the same regardless of whether the operations are done within a transaction.
Calling Begin() returns a Session that is a transaction, and calling Commit() on the resultant session (transaction) commits the transaction.
The db field is non-nil for a new session. For an open transaction, db is nil and tx is non-nil. Once Commit() is called on the transaction, both the db and tx are nil (and any method calls on this object will fail).
func NewInMemory ¶ added in v0.3.2
func (*Session) AllDuplicates ¶
func (s *Session) AllDuplicates(path string) ([]DuplicateSet, herror.Interface)
func (*Session) AllDuplicatesC ¶
func (s *Session) AllDuplicatesC(path string) (<-chan DuplicateSet, herror.Interface)
Returns all known duplicates in the database.
These are necessarily FileInfos with the FullHash field filled out. Each DuplicateSet that is returned always has > 1 element (i.e. it only includes duplicates, not infos where we happen to know the full hash).
path is optional; if "", then all duplicates are returned, otherwise only ones with the given directory prefix
func (*Session) AllInfosC ¶
Returns all infos in the database (regardless of whether they have duplicates).
func (*Session) CreateIndexes ¶
func (*Session) InfosBySize ¶
Returns all the infos with the given size.
This includes all infos, even ones where the short hash or full hash is not known.
func (*Session) Lookup ¶
func (s *Session) Lookup(path string) (DuplicateSet, herror.Interface)
Returns info for everything matching the given file.
Returns [] if there isn't a matching file in the database. If the file exists in the database, that file is returned first.
func (*Session) LookupAllC ¶
func (s *Session) LookupAllC(path string, includeHidden bool) (<-chan DuplicateInfo, herror.Interface)
Returns all duplicate sets (size > 1) where at least one file is contained under the given path.
func (*Session) RemoveDir ¶
Deletes all files matching the given directory prefix from the database, with sizes in the specified range.
A max size of 0 is interpreted as infinity. This does not just match based on prefix, it interprets the prefix as a directory, and only deletes files under the given directory. This means that it won't accidentally match file names (or other directory names) where the prefix is common, e.g. deleting "/a" won't delete file "/aa" or contents under a directory "/aa".