download

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrAlreadyExists = errors.New("file already exists")

ErrAlreadyExists is returned by Fetch when a file with the same name already exists in the download directory.

View Source
var ErrDuplicateContent = errors.New("duplicate content")

ErrDuplicateContent is returned by Fetch when the downloaded content has a SHA-256 hash that matches an existing file in the download directory.

Functions

func BuildHashIndex

func BuildHashIndex(dir string) (map[string]bool, error)

BuildHashIndex scans dir for image files (.jpg, .jpeg, .png, .webp) and returns a map of hex-encoded SHA-256 hashes to true.

func InvalidateSkwdCache

func InvalidateSkwdCache(path string)

InvalidateSkwdCache removes the skwd checksum file at path. If the file does not exist the call is a no-op.

Types

type Downloader

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

Downloader manages downloading wallpapers to a directory with deduplication.

func New

func New(dir string, hashIndex map[string]bool) *Downloader

New creates a Downloader that saves files to dir. hashIndex is the set of known SHA-256 hashes (hex-encoded) already present in dir; callers should build it with BuildHashIndex.

func (*Downloader) Fetch

func (d *Downloader) Fetch(result source.WallpaperResult) (string, error)

Fetch downloads the wallpaper described by result into the Downloader's directory. It returns the path to the saved file. The following sentinel errors may be returned:

  • ErrAlreadyExists: a file with the same name already exists.
  • ErrDuplicateContent: the downloaded bytes match an existing file's hash.

Jump to

Keyboard shortcuts

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