Skip to content

Commit 343ef0b

Browse files
rectify control of progress callback
1 parent dbb0625 commit 343ef0b

File tree

3 files changed

+5
-11
lines changed

3 files changed

+5
-11
lines changed

src/Curl/Easy.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ mutable struct Easy
44
ready :: Threads.Event
55
seeker :: Union{Function,Nothing}
66
output :: Channel{Vector{UInt8}}
7-
progress :: Channel{NTuple{4,Int}}
7+
progress :: Function
88
req_hdrs :: Ptr{curl_slist_t}
99
res_hdrs :: Vector{String}
1010
code :: CURLcode
@@ -13,14 +13,14 @@ end
1313

1414
const EMPTY_BYTE_VECTOR = UInt8[]
1515

16-
function Easy()
16+
function Easy(progress::Union{Function,Nothing})
1717
easy = Easy(
1818
curl_easy_init(),
1919
EMPTY_BYTE_VECTOR,
2020
Threads.Event(),
2121
nothing,
2222
Channel{Vector{UInt8}}(Inf),
23-
Channel{NTuple{4,Int}}(Inf),
23+
something(progress, (_, _, _, _) -> nothing),
2424
C_NULL,
2525
String[],
2626
typemax(CURLcode),
@@ -372,7 +372,7 @@ function progress_callback(
372372
ul_now :: curl_off_t,
373373
)::Cint
374374
easy = unsafe_pointer_to_objref(easy_p)::Easy
375-
put!(easy.progress, (dl_total, dl_now, ul_total, ul_now))
375+
easy.progress(dl_total, dl_now, ul_total, ul_now)
376376
return 0
377377
end
378378

src/Curl/Multi.jl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,6 @@ function check_multi_info(multi::Multi)
8585
easy = unsafe_pointer_to_objref(easy_p_ref[])::Easy
8686
@assert easy_handle == easy.handle
8787
easy.code = message.code
88-
close(easy.progress)
8988
close(easy.output)
9089
easy.input = nothing
9190
notify(easy.ready)

src/Downloads.jl

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ function request(
308308
progress = p_func(progress, input, output)
309309
arg_read(input) do input
310310
arg_write(output) do output
311-
with_handle(Easy()) do easy
311+
with_handle(Easy(progress)) do easy
312312
# setup the request
313313
set_url(easy, url)
314314
set_timeout(easy, timeout)
@@ -348,11 +348,6 @@ function request(
348348
@async for buf in easy.output
349349
write(output, buf)
350350
end
351-
if progress !== nothing
352-
@async for prog in easy.progress
353-
progress(prog...)
354-
end
355-
end
356351
if have_input
357352
@async upload_data(easy, input)
358353
end

0 commit comments

Comments
 (0)