Skip to content

Commit 2624736

Browse files
authored
Merge pull request #42 from rofinn/rf/download2str
Adds a fallback download method for when the destination is a string
2 parents 720f20f + d142fd0 commit 2624736

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

src/path.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -562,6 +562,11 @@ end
562562

563563
Base.download(url::AbstractPath, localfile::AbstractPath) = cp(url, localfile; force=true)
564564

565+
function Base.download(url::AbstractPath, localfile::AbstractString)
566+
download(url, Path(localfile))
567+
return localfile
568+
end
569+
565570
"""
566571
readpath(fp::P) where {P <: AbstractPath} -> Vector{P}
567572
"""

src/test.jl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -761,7 +761,10 @@ module TestPaths
761761
download(ps.foo / "README.md", ps.qux / "README.md")
762762
@test exists(ps.qux / "README.md")
763763

764-
rm.([ps.foo / "README.md", ps.qux / "README.md"])
764+
# Test downloading to a string
765+
download(ps.foo / "README.md", string(ps.fred / "README.md"))
766+
@test exists(ps.fred / "README.md")
767+
rm.([ps.foo / "README.md", ps.qux / "README.md", ps.fred / "README.md"])
765768
end
766769
end
767770

0 commit comments

Comments
 (0)