Properly resolve shorthands to HTTPS URL packages

This commit is contained in:
Richard Feldman 2022-11-22 08:28:54 -05:00
parent d16b247523
commit 092d21a663
No known key found for this signature in database
GPG key ID: F1F21AA5B1D9E43B
5 changed files with 148 additions and 50 deletions

View file

@ -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);

View file

@ -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,
})

View file

@ -1,3 +1,3 @@
pub mod cache;
mod https;
pub mod https;
pub mod tarball;