mirror of
https://github.com/roc-lang/roc.git
synced 2025-08-03 19:58:18 +00:00
Properly resolve shorthands to HTTPS URL packages
This commit is contained in:
parent
d16b247523
commit
092d21a663
5 changed files with 148 additions and 50 deletions
|
@ -33,7 +33,7 @@ pub fn install_package<'a>(
|
|||
url: &'a str,
|
||||
) -> Result<(PathBuf, Option<&'a str>), Problem> {
|
||||
let PackageMetadata {
|
||||
cache_subfolder,
|
||||
cache_subdir,
|
||||
content_hash,
|
||||
root_module_filename,
|
||||
} = PackageMetadata::try_from(url).map_err(Problem::InvalidUrl)?;
|
||||
|
@ -41,7 +41,7 @@ pub fn install_package<'a>(
|
|||
match roc_cache_dir {
|
||||
RocCacheDir::Persistent(cache_dir) => {
|
||||
// e.g. ~/.cache/roc/example.com/roc-packages/
|
||||
let parent_dir = cache_dir.join(cache_subfolder);
|
||||
let parent_dir = cache_dir.join(cache_subdir);
|
||||
// e.g. ~/.cache/roc/example.com/roc-packages/jDRlAFAA3738vu3-vMpLUoyxtA86Z7CaZneoOKrihbE
|
||||
let dest_dir = parent_dir.join(content_hash);
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ pub struct PackageMetadata<'a> {
|
|||
/// The BLAKE3 hash of the tarball's contents. Also the .tar filename on disk.
|
||||
pub content_hash: &'a str,
|
||||
/// On disk, this will be the subfolder inside the cache dir where the package lives
|
||||
pub cache_subfolder: &'a str,
|
||||
pub cache_subdir: &'a str,
|
||||
/// Other code will default this to main.roc, but this module isn't concerned with that default.
|
||||
pub root_module_filename: Option<&'a str>,
|
||||
}
|
||||
|
@ -95,7 +95,7 @@ impl<'a> PackageMetadata<'a> {
|
|||
};
|
||||
|
||||
Ok(PackageMetadata {
|
||||
cache_subfolder: path,
|
||||
cache_subdir: path,
|
||||
content_hash: tarball_name,
|
||||
root_module_filename: fragment,
|
||||
})
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
pub mod cache;
|
||||
mod https;
|
||||
pub mod https;
|
||||
pub mod tarball;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue