Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FileStats ¶
type FileStats struct { Base64Path string Size int64 UID uint32 GID uint32 Atim int64 Mtim int64 Ctim int64 Type FileType Ino uint64 Nlink uint64 Dev uint64 }
FileStats contains all the file stats needed by wrstat, interpreted in our custom way.
type Operation ¶
Operation is a callback that once added to a Paths will be called on each path encountered. It receives the absolute path to the filesystem entry, and the FileInfo returned by Statter.Lstat() on that path.
func FileOperation ¶
FileOperation returns an Operation that can be used with Paths that calls File() on each path the Operation receives and outputs the ToString() value to the given output file.
type Paths ¶
type Paths struct {
// contains filtered or unexported fields
}
Paths lets you get stats and carry out operations on those stats for many file paths.
func NewPaths ¶
NewPaths returns a Paths that will use the given Statter to do the Lstat calls and log issues to the logger. If you supply a reportFrequency greater than 0, then timings for the lstats and your operations will also be logged.
func (*Paths) AddOperation ¶
AddOperation adds the given Operation callback so that when you Scan(), your callback will be called for each path scanned. You give the operation a name so that timings can be reported for each operation.
You can't use the name "lstat", since that is used for reporting the Lstat timings.
func (*Paths) Scan ¶
Scan scans through the given reader which should consist of an absolute file path per line. It calls our Statter.Lstat() on each, and passes the absolute path and FileInfo to any Operation callbacks you've added.
Operations are run concurrently (so should not do something like write to the same file) and their errors logged, but otherwise ignored.
We wait for all operations to complete before they are all called again, so it is safe to do something like write stat details to a file.
type Statter ¶
type Statter interface { // Lstat calls os.Lstat() on the given path, returning the FileInfo. Lstat(path string) (info fs.FileInfo, err error) }
Statter is something you use to get stats of files on disk.
type StatterWithTimeout ¶
type StatterWithTimeout struct {
// contains filtered or unexported fields
}
StatterWithTimeout is is a Statter implementation. NB: this is NOT thread safe; you should only call Lstat() one at a time.
func WithTimeout ¶
WithTimeout returns a Statter with the given timeout and maxAttempts configured. Timeouts are logged with the given logger.
func (*StatterWithTimeout) Lstat ¶
func (s *StatterWithTimeout) Lstat(path string) (info fs.FileInfo, err error)
Lstat calls os.Lstat() on the given path, but times it out after our configured timeout, retrying until we've hit our maxAttempts. NB: this is NOT thread safe, don't call this concurrently.