state

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultInlineHashTimeout = 10 * time.Second
)

Variables

This section is empty.

Functions

func AddToMasterList

func AddToMasterList(entry types.DownloadEntry) error

func CheckDownloadExists

func CheckDownloadExists(url string) (bool, error)

func ClearRateLimit added in v0.9.0

func ClearRateLimit(id string) error

ClearRateLimit removes a download-specific rate limit override.

func CloseDB

func CloseDB()

func Configure

func Configure(path string)

Configure sets the base directory for the custom state backend. It accepts a file path (e.g., legacy downloads.db) for backward compatibility, avoiding a massive refactor of all startup paths that pass a database file path. It extracts and uses the parent directory for Gob state.

func DeleteState

func DeleteState(id string) error

func DeleteTasks

func DeleteTasks(id string) error

func GetDownload

func GetDownload(id string) (*types.DownloadEntry, error)

func ListAllDownloads

func ListAllDownloads() ([]types.DownloadEntry, error)

func LoadCompletedDownloads

func LoadCompletedDownloads() ([]types.DownloadEntry, error)

func LoadMasterList

func LoadMasterList() (*types.MasterList, error)

func LoadPausedDownloads

func LoadPausedDownloads() ([]types.DownloadEntry, error)

func LoadState

func LoadState(url string, destPath string) (*types.DownloadState, error)

func LoadStates

func LoadStates(ids []string) (map[string]*types.DownloadState, error)

func NormalizeStaleDownloads

func NormalizeStaleDownloads() (int, error)

NormalizeStaleDownloads resets downloads that were interrupted (e.g., app crash) and appear as dead/frozen items in the TUI.

func PauseAllDownloads

func PauseAllDownloads() error

func RemoveCompletedDownloads

func RemoveCompletedDownloads() (int64, error)

func RemoveFailedDownloads added in v0.10.0

func RemoveFailedDownloads() (int64, error)

func RemoveFromMasterList

func RemoveFromMasterList(id string) error

func ResumeAllDownloads

func ResumeAllDownloads() error

func SaveState

func SaveState(url string, destPath string, state *types.DownloadState) error

func SaveStateWithOptions

func SaveStateWithOptions(url string, destPath string, state *types.DownloadState, opts SaveStateOptions) error

func URLHash

func URLHash(url string) string

func UpdateDefaultRateLimit added in v0.9.0

func UpdateDefaultRateLimit(id string, rate int64) error

UpdateDefaultRateLimit updates the inherited rate limit of a download only if the download does not have a user-set override.

func UpdateRateLimit added in v0.9.0

func UpdateRateLimit(id string, rate int64) error

UpdateRateLimit updates the rate limit of a download in the database

func UpdateStatus

func UpdateStatus(id string, status string) error

func UpdateURL

func UpdateURL(id string, newURL string) error

func ValidateIntegrity

func ValidateIntegrity() (int, error)

ValidateIntegrity checks that paused .surge files still exist and haven't been tampered with. Removes orphaned or corrupted entries from the master list. Returns the number of entries removed.

Types

type DetailState added in v0.10.0

type DetailState struct {
	Version int
	State   *types.DownloadState
}

type MasterState added in v0.10.0

type MasterState struct {
	Version   int
	Downloads []types.DownloadEntry
}

type SaveStateOptions

type SaveStateOptions struct {
	// SkipFileHash disables file_hash computation entirely for this save.
	SkipFileHash bool
	// InlineHashTimeout limits synchronous hashing time. If zero or negative, DefaultInlineHashTimeout is used.
	InlineHashTimeout time.Duration
}

Jump to

Keyboard shortcuts

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