Documentation
¶
Index ¶
- Constants
- func AddToMasterList(entry types.DownloadEntry) error
- func CheckDownloadExists(url string) (bool, error)
- func CloseDB()
- func Configure(path string)
- func DeleteState(id string) error
- func DeleteTasks(id string) error
- func GetDB() (*sql.DB, error)
- func GetDownload(id string) (*types.DownloadEntry, error)
- func ListAllDownloads() ([]types.DownloadEntry, error)
- func LoadCompletedDownloads() ([]types.DownloadEntry, error)
- func LoadMasterList() (*types.MasterList, error)
- func LoadPausedDownloads() ([]types.DownloadEntry, error)
- func LoadState(url string, destPath string) (*types.DownloadState, error)
- func LoadStates(ids []string) (map[string]*types.DownloadState, error)
- func NormalizeStaleDownloads() (int, error)
- func PauseAllDownloads() error
- func RemoveCompletedDownloads() (int64, error)
- func RemoveFromMasterList(id string) error
- func ResumeAllDownloads() error
- func SaveState(url string, destPath string, state *types.DownloadState) error
- func SaveStateWithOptions(url string, destPath string, state *types.DownloadState, opts SaveStateOptions) error
- func URLHash(url string) string
- func UpdateStatus(id string, status string) error
- func UpdateURL(id string, newURL string) error
- func ValidateIntegrity() (int, error)
- type SaveStateOptions
Constants ¶
const ( // DefaultInlineHashTimeout bounds synchronous hash work during pause persistence. // If hashing takes longer than this, we skip storing file_hash for this snapshot. DefaultInlineHashTimeout = 10 * time.Second )
Variables ¶
This section is empty.
Functions ¶
func AddToMasterList ¶
func AddToMasterList(entry types.DownloadEntry) error
AddToMasterList adds or updates a download entry
func CheckDownloadExists ¶
CheckDownloadExists checks if a download with the given URL exists in the database
func DeleteTasks ¶
DeleteTasks removes chunk task rows while preserving the download entry itself.
func GetDB ¶
GetDB is safe for concurrent use; it lazily opens the database so callers need not coordinate initialisation order with Configure().
func GetDownload ¶
func GetDownload(id string) (*types.DownloadEntry, error)
GetDownload returns a single download by ID
func ListAllDownloads ¶
func ListAllDownloads() ([]types.DownloadEntry, error)
ListAllDownloads returns all downloads
func LoadCompletedDownloads ¶
func LoadCompletedDownloads() ([]types.DownloadEntry, error)
LoadCompletedDownloads returns all completed downloads
func LoadMasterList ¶
func LoadMasterList() (*types.MasterList, error)
LoadMasterList loads ALL downloads (paused and completed)
func LoadPausedDownloads ¶
func LoadPausedDownloads() ([]types.DownloadEntry, error)
LoadPausedDownloads returns all paused downloads
func LoadState ¶
func LoadState(url string, destPath string) (*types.DownloadState, error)
LoadState loads download state from SQLite
func LoadStates ¶
func LoadStates(ids []string) (map[string]*types.DownloadState, error)
LoadStates loads multiple download states from SQLite in batch
func NormalizeStaleDownloads ¶
NormalizeStaleDownloads converts any downloads stuck in "downloading" status to "paused". This handles crash recovery: if the process was killed (SIGKILL, power loss, terminal close without graceful shutdown) while a download was active, the entry remains in "downloading" status with no worker attached. Without normalization these entries are invisible to resumePausedDownloads() and appear as dead/frozen items in the TUI.
func PauseAllDownloads ¶
func PauseAllDownloads() error
PauseAllDownloads pauses all non-completed downloads
func RemoveCompletedDownloads ¶
RemoveCompletedDownloads removes all completed downloads and returns count
func RemoveFromMasterList ¶
RemoveFromMasterList removes a download entry
func ResumeAllDownloads ¶
func ResumeAllDownloads() error
ResumeAllDownloads resumes all paused downloads (sets to queued)
func SaveState ¶
func SaveState(url string, destPath string, state *types.DownloadState) error
SaveState saves download state to SQLite
func SaveStateWithOptions ¶
func SaveStateWithOptions(url string, destPath string, state *types.DownloadState, opts SaveStateOptions) error
SaveStateWithOptions saves download state to SQLite with custom persistence options.
func URLHash ¶
URLHash returns a short hash of the URL for master list keying This is used for tracking completed downloads by URL
func UpdateStatus ¶
UpdateStatus updates the status of a download by ID
func ValidateIntegrity ¶
ValidateIntegrity checks that paused .surge files still exist and haven't been tampered with. Removes orphaned or corrupted entries from the database. Returns the number of entries removed.
Types ¶
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
}
SaveStateOptions controls pause-state persistence behavior.