Documentation ¶
Index ¶
- func FormatTime(t time.Time) string
- func RoundTime(t time.Time) time.Time
- type Cache
- func (cache *Cache) Close() error
- func (cache *Cache) Flush() error
- func (cache *Cache) FlushThreshold(threshold int)
- func (cache *Cache) ForEach(f RangeFunc)
- func (cache *Cache) Get(path string) (QuickCheck, bool)
- func (cache *Cache) Read(r io.Reader) error
- func (cache *Cache) Store(path string, stat os.FileInfo, info archive.Info) error
- func (cache *Cache) WriteTo(w io.Writer) (n int64, err error)
- type QuickCheck
- type RangeFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FormatTime ¶ added in v0.9.0
func RoundTime ¶ added in v0.9.0
Both the client and the original patcher treat the modification time as a floating point number, and then rounding to 6 decimal places.
Because of imprecisions within floating point numbers, the original patch (and therefore client) expect a slightly incorrect nanoseconds value, thus causing a typically off-by-one rounding error.
For example, if a file has a modification time of 1729218809s + 315336400ns, the correctly rounded nanoscond value should be 315336000ns (1729218809.315336). Instead, the client considers the floating point time as 1729218809.3153365s, thus causing it to round the nanoseconds to 315337000ns (1729218809.315337) instead.
Types ¶
type Cache ¶
type Cache struct {
// contains filtered or unexported fields
}
func New ¶
Creates a new *Cache with an optional flush threshold. The provided *os.File is used as persistent storage for the cache's QuickCheck values. New does NOT parse and store the contents of the given file.
func Open ¶
Creates a new *Cache with an optional flush threshold from the file specified by name. Open creates the file if it doesn't already exist.
If opening the file does not return an error, Open parses and stores the contents of that file. If an error occurs when reading the file, the file is immediately closed and that error is returned.
func (*Cache) Close ¶
Flushes the cache's contents, if necessary, to the underlying *os.File, and then closes the file.
func (*Cache) Flush ¶
Writes the cache's contents, in it's entirety, to the underlying *os.File, and resets the cache's internal state.
func (*Cache) FlushThreshold ¶
func (*Cache) Get ¶
func (cache *Cache) Get(path string) (QuickCheck, bool)
Returns the QuickCheck value for the given path.
func (*Cache) Read ¶
Parses the contents of provided io.Reader and stores valid QuickCheck values into the cache. Read returns the first parse error that occurs or any error that is returned from the provided io.Reader. Valid QuickCheck values parsed prior to a parse error are still stored.
func (*Cache) Store ¶
Sets the QuickCheck of the provided file to the given path as its key. The path is always passed through filepath.FromSlash before being stored.
If the number of changes (# modifications + # additions) >= the configured flush threshold, the cache's contents are flushed to underlying *os.File. The result of this flush is NOT guaranteed to be equivalent to calling Flush.
type QuickCheck ¶
type RangeFunc ¶
type RangeFunc = func(qc QuickCheck) bool