cache

package
v0.14.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 31, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatTime added in v0.9.0

func FormatTime(t time.Time) string

func RoundTime added in v0.9.0

func RoundTime(t time.Time) time.Time

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.

func Write added in v0.10.0

func Write(w io.Writer, c *Cache) (err error)

Writes a *Cache's quick check entries to the provided io.Writer.

func WriteFile added in v0.10.0

func WriteFile(name string, c *Cache) error

Writes a *Cache's quick check entries to the named file.

Types

type Cache

type Cache struct {
	// contains filtered or unexported fields
}

File type: txt

The cache file, named quickcheck.txt in the orignial patcher, stored a list of comma-separated values for the states of unpacked client resources from when the patcher was last run. If any of the non-path values (modification time, size, or uncompressed checksum) have changed, the unpacked resource should be reinstalled.

Each line in the file takes the form:

%s,%d.%06d,%d,%x

With these values associated with an unpacked resource:

  1. The relative path
  2. The modification time seconds
  3. The modification time milliseconds (padded to 6 digits)
  4. The size of the resource
  5. The md5 hash of the resource

func Read added in v0.10.0

func Read(r io.Reader, options ...ReadOptions) (*Cache, error)

Creates a *Cache from the entries scanned from the provided io.Reader. Read immediately returns an error if it fails to scan a line or parse a quick check entry.

func ReadFile added in v0.10.0

func ReadFile(name string, options ...ReadOptions) (*Cache, error)

Creates a *Cache from the entries scanned from the named file. Read immediately returns an error if it fails to scan a line or parse a quick check entry.

func (*Cache) All added in v0.10.0

func (c *Cache) All() iter.Seq[QuickCheck]

func (*Cache) Len added in v0.10.0

func (c *Cache) Len() (length int)

func (*Cache) Load added in v0.10.0

func (c *Cache) Load(path string) (QuickCheck, bool)

func (*Cache) Range added in v0.10.0

func (c *Cache) Range(f RangeFunc)

func (*Cache) Store

func (c *Cache) Store(path string, stat os.FileInfo, info archive.Info)

type QuickCheck

type QuickCheck interface {
	Path() string
	ModTime() time.Time
	Size() int64
	Checksum() []byte

	Check(os.FileInfo, archive.Info) error
}

type RangeFunc

type RangeFunc = func(qc QuickCheck) bool

type ReadOptions added in v0.12.1

type ReadOptions struct {
	// Ignore malformed cache data
	IgnoreUnmarshalErrors bool
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL