Function: ghostel--download-module
ghostel--download-module is a natively compiled function defined in
ghostel-module-install.el.
Signature
(ghostel--download-module DIR &optional VERSION LATEST-RELEASE)
Documentation
Download a pre-built module into DIR.
When VERSION is non-nil, download that release tag. When LATEST-RELEASE is non-nil, use the latest release asset URL. On success, also writes the sidecar version file alongside the module. Returns non-nil on success.
Source Code
;; Defined in /nix/store/1252krff0gb2kisjcpp45m50cpdskfrl-emacs-packages-deps/share/emacs/site-lisp/ghostel-module-install.el
(defun ghostel--download-module (dir &optional version latest-release)
"Download a pre-built module into DIR.
When VERSION is non-nil, download that release tag.
When LATEST-RELEASE is non-nil, use the latest release asset URL.
On success, also writes the sidecar version file alongside the module.
Returns non-nil on success."
(condition-case err
(let* ((requested-version (unless latest-release
(or version ghostel--minimum-module-version)))
(url (ghostel--module-download-url requested-version)))
(when url
(unless (string-prefix-p "https://" url)
(error "Refusing non-HTTPS download URL: %s" url))
(make-directory dir t)
(let ((dest (expand-file-name
(concat "ghostel-module" module-file-suffix) dir))
(sidecar (ghostel--module-sidecar-path dir)))
;; Drop any pre-existing sidecar so that, if the download or the
;; subsequent sidecar write fails partway, the loader sees `absent'
;; rather than `stale' (refuse to map a fresh module).
(when (file-exists-p sidecar)
(delete-file sidecar))
(message "ghostel: downloading native module from %s..." url)
(when-let* ((final-url (ghostel--download-file url dest)))
;; Resolve the version that was actually fetched. For an
;; explicit version we trust the request; for `latest' we
;; parse the URL the server redirected us to. If parsing
;; fails we fall back to the minimum so the sidecar still
;; reflects a safe lower bound.
(let* ((downloaded-version (ghostel--release-version-from-url final-url))
(resolved (or requested-version
downloaded-version
ghostel--minimum-module-version)))
(ghostel--install-support-assets
dir (or requested-version downloaded-version))
(ghostel--write-module-sidecar-version dir resolved))
(message "ghostel: native module downloaded successfully")
t))))
(error
(message "ghostel: download failed: %s" (error-message-string err))
nil)))