Skip to content

Commit

Permalink
Add file:/// handling in download tool (#2635)
Browse files Browse the repository at this point in the history
* Add file:/// handling in download tool

* Add Windows example and note that it's only for absolute paths
  • Loading branch information
jcar87 committed Jul 27, 2022
1 parent 7ae0add commit 0384c39
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion reference/conanfile/tools/files/downloads.rst
Expand Up @@ -90,6 +90,8 @@ Parameters:

- **conanfile** (Required): Conanfile object, use ``self`` always
- **url** (Required): URL to download. It can be a list, which only the first one will be downloaded, and the follow URLs will be used as mirror in case of download error.
Files accessible in the local filesystem can be referenced with a URL starting with ``file:///`` followed by an absolute path to a file
(where the third ``/`` implies ``localhost``).
- **filename** (Required): Name of the file to be created in the local storage
- **verify** (Optional, Defaulted to ``True``): When False, disables https certificate validation.
- **retry** (Optional, Defaulted to ``1``): Number of retries in case of failure.
Expand Down Expand Up @@ -127,9 +129,14 @@ Examples:
# Download and check file checksum
download(self, "http://someurl/somefile.zip", "myfilename.zip", md5="e5d695597e9fa520209d1b41edad2a27")
# Retrieve file that is visible in the local filesystem
tools.download("file:///C:/Users/MyUser/Downloads/somefile.zip", "myfilename.zip", md5="e5d695597e9fa520209d1b41edad2a27")
tools.download("file:///home/myuser/downloads/somefile.zip", "myfilename.zip", md5="e5d695597e9fa520209d1b41edad2a27")
# to add mirrors
download(self, ["https://ftp.gnu.org/gnu/gcc/gcc-9.3.0/gcc-9.3.0.tar.gz",
"http://mirror.linux-ia64.org/gnu/gcc/releases/gcc-9.3.0/gcc-9.3.0.tar.gz"],
"http://mirror.linux-ia64.org/gnu/gcc/releases/gcc-9.3.0/gcc-9.3.0.tar.gz",
"file:///home/myuser/localmirror/gcc-9.3.0/gcc-9.3.0.tar.gz"],
"gcc-9.3.0.tar.gz",
sha256="5258a9b6afe9463c2e56b9e8355b1a4bee125ca828b8078f910303bc2ef91fa6")
Expand Down

0 comments on commit 0384c39

Please sign in to comment.