Skip to content

l0.DependencyControl.shims.DownloadManager

DownloadManager = require "l0.DependencyControl.shims.DownloadManager"
local DownloadManager = require("l0.DependencyControl.shims.DownloadManager")

DownloadManager

A download manager replicating the DM.DownloadManager API on top of the DependencyControl Downloader engine.

Constructor

downloadManager = DownloadManager etagCacheDir
local downloadManager = DownloadManager(etagCacheDir)

Creates a download manager.

param type description
etagCacheDir? string Accepted for API compatibility; ETag caching is not implemented.

Instance methods

addDownload

downloadManager\addDownload url, outfile, sha1, etag
downloadManager:addDownload(url, outfile, sha1, etag)

Queues a download, optionally verifying its SHA-1 once complete.

param type description
url string
outfile string Full output path.
sha1? string Expected SHA-1 hash.
etag? string Accepted for API compatibility; ignored.

Returns:

waitForFinish

downloadManager\waitForFinish callback
downloadManager:waitForFinish(callback)

Performs all queued downloads (DM.DownloadManager-compatible).

param type description
callback? fun(progress: number): any Called with 0-100; returning a falsy value cancels remaining downloads. Bridged to the engine's Progress event.

progress

downloadManager\progress!
downloadManager:progress()

Returns:

  • progress number — Current aggregate progress (0-100).

cancel

downloadManager\cancel!
downloadManager:cancel()

Cancels all remaining queued downloads.

clear

downloadManager\clear!
downloadManager:clear()

Removes all queued downloads and resets state; existing .downloads references stay valid.

isInternetConnected

downloadManager\isInternetConnected!
downloadManager:isInternetConnected()

Returns:

  • connected boolean — Whether an internet connection appears to be available.

getFileSHA1

downloadManager\getFileSHA1 filename
downloadManager:getFileSHA1(filename)

Computes the SHA-1 of a file's contents.

param type description
filename string

Returns:

  • hexDigest string?
  • err string?

checkFileSHA1

downloadManager\checkFileSHA1 filename, expected
downloadManager:checkFileSHA1(filename, expected)

Verifies a file against an expected SHA-1 hash.

param type description
filename string
expected string Expected SHA-1 hex digest.

Returns:

  • match boolean?
  • err string?

checkStringSHA1

downloadManager\checkStringSHA1 str, expected
downloadManager:checkStringSHA1(str, expected)

Verifies a string against an expected SHA-1 hash.

param type description
str string
expected string Expected SHA-1 hex digest.

Returns:

  • match boolean?
  • err string?

Fields

field type description
version string