Skip to content

Commit bcc5ac0

Browse files
committed
more aggressive removal of preceding and trailing '/'s from container and prefix's
1 parent ecc7e30 commit bcc5ac0

File tree

3 files changed

+26
-9
lines changed

3 files changed

+26
-9
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "AzStorage"
22
uuid = "c6697862-1611-5eae-9ef8-48803c85c8d6"
3-
version = "2.7.0"
3+
version = "2.7.1"
44

55
[deps]
66
AbstractStorage = "14dbef02-f468-5f15-853e-5ec8dee7b899"

src/AzStorage.jl

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -138,22 +138,23 @@ The storage account must already exist.
138138
* `verbose=0` verbosity flag passed to libcurl.
139139
140140
# Notes
141-
The container name can container "/"'s. If this is the case, then the string preceding the first "/" will
141+
The container name can contain "/"'s. If this is the case, then the string preceding the first "/" will
142142
be the container name, and the string that remains will be pre-pended to the blob names. This allows Azure
143-
to present blobs in a pseudo-directory structure.
143+
to present blobs in a pseudo-directory structure. Note that trailing and leading `/`'s are ignored.
144144
"""
145145
function AzContainer(containername::AbstractString; storageaccount, session=AzSession(;lazy=false, scope=__OAUTH_SCOPE), nthreads=Sys.CPU_THREADS, connect_timeout=10, read_timeout=30, nretry=10, verbose=0, prefix="")
146-
name = split(containername, '/')
146+
name = split(strip(containername, '/'), '/')
147147
_containername = name[1]
148-
prefix *= lstrip('/'*join(name[2:end], '/'), '/')
148+
prefix = strip(strip(prefix, '/')*'/'*join(name[2:end], '/'), '/')
149+
149150
AzContainer(String(storageaccount), String(_containername), String(prefix), session, windows_one_thread(nthreads), connect_timeout, read_timeout, nretry, verbose)
150151
end
151152

152153
function AbstractStorage.Container(::Type{<:AzContainer}, d::Dict, session=AzSession(;lazy=false, scope=__OAUTH_SCOPE); nthreads=Sys.CPU_THREADS, connect_timeout=10, read_timeout=30, nretry=10, verbose=0)
153154
AzContainer(
154155
d["storageaccount"],
155-
d["containername"],
156-
d["prefix"],
156+
String(strip(d["containername"], '/')),
157+
String(strip(d["prefix"], '/')),
157158
session,
158159
windows_one_thread(get(d, "nthreads", nthreads)),
159160
connect_timeout,

test/runtests.jl

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -737,7 +737,24 @@ if !Sys.iswindows() && !Sys.isapple()
737737
@test data _data
738738
end
739739

740-
@testset "performance counters" begin
740+
@testset "remove leading/training slashes" begin
741+
r = uuid4()
742+
c = AzContainer("foo-$r-o", storageaccount=storageaccount, session=session)
743+
@test c.prefix == ""
744+
@test c.containername == "foo-$r-o"
745+
c = AzContainer("foo-$r-o/bar/", storageaccount=storageaccount, session=session)
746+
@test c.prefix == "bar"
747+
@test c.containername == "foo-$r-o"
748+
c = AzContainer("foo-$r-o/bar/baz/", storageaccount=storageaccount, session=session)
749+
@test c.prefix == "bar/baz"
750+
@test c.containername == "foo-$r-o"
751+
c = AzContainer("foo-$r-o/bar/baz/", storageaccount=storageaccount, session=session, prefix="/one/two/")
752+
@test c.prefix == "one/two/bar/baz"
753+
@test c.containername == "foo-$r-o"
754+
end
755+
756+
757+
@test_skip @testset "performance counters" begin
741758
perfcounters = AzStorage.getperf_counters()
742759
@info "Throttled events = $(perfcounters.count_throttled), Throttled ms wait: = $(perfcounters.ms_wait_throttled)"
743760

@@ -753,5 +770,4 @@ if !Sys.iswindows() && !Sys.isapple()
753770
@test_skip @test perfcounters.count_throttled == 0
754771
@test_skip @test perfcounters.count_timeouts == 0
755772
end
756-
757773
end

0 commit comments

Comments
 (0)