Skip to content

Commit

Permalink
fix: fix url dependency caching when special urlencoded chars (python…
Browse files Browse the repository at this point in the history
  • Loading branch information
ralbertazzi authored May 14, 2023
1 parent e5bbc60 commit ee567a7
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions src/poetry/packages/direct_origin.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
from __future__ import annotations

import functools
import os
import urllib.parse

from pathlib import Path
from typing import TYPE_CHECKING
Expand Down Expand Up @@ -77,20 +75,19 @@ def get_package_from_directory(cls, directory: Path) -> Package:
return PackageInfo.from_directory(path=directory).to_package(root_dir=directory)

def get_package_from_url(self, url: str) -> Package:
file_name = os.path.basename(urllib.parse.urlparse(url).path)
link = Link(url)
artifact = self._artifact_cache.get_cached_archive_for_link(link, strict=True)

if not artifact:
artifact = (
self._artifact_cache.get_cache_directory_for_link(link) / file_name
self._artifact_cache.get_cache_directory_for_link(link) / link.filename
)
artifact.parent.mkdir(parents=True, exist_ok=True)
download_file(url, artifact)

package = self.get_package_from_file(artifact)
package.files = [
{"file": file_name, "hash": "sha256:" + get_file_hash(artifact)}
{"file": link.filename, "hash": "sha256:" + get_file_hash(artifact)}
]

package._source_type = "url"
Expand Down

0 comments on commit ee567a7

Please sign in to comment.