Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added testsets and an upload function that can do retries #42

Merged
merged 7 commits into from
Jan 22, 2018

Conversation

nick-thiessen
Copy link

-new upload function
-tests for new upload function
-test sets for ftp_object

src/FTPObject.jl Outdated
"""
function upload(
ftp::FTP,
local_file_paths::Vector{<:AbstractString},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This syntax is only available on Julia 0.6 and later. You should be able to do this if you write:

@compat function upload(
    ftp::FTP,
    local_file_paths::Vector{<:AbstractString},
    ...

@codecov
Copy link

codecov bot commented Jul 14, 2017

Codecov Report

Merging #42 into master will decrease coverage by 0.01%.
The diff coverage is 91.3%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #42      +/-   ##
==========================================
- Coverage   90.71%   90.69%   -0.02%     
==========================================
  Files           3        3              
  Lines         237      258      +21     
==========================================
+ Hits          215      234      +19     
- Misses         22       24       +2
Impacted Files Coverage Δ
src/FTPClient.jl 100% <ø> (ø) ⬆️
src/FTPC.jl 96.36% <100%> (ø) ⬆️
src/FTPObject.jl 80.21% <90.9%> (+3.4%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update cca2290...600278f. Read the comment docs.

src/FTPC.jl Outdated
@@ -125,9 +127,9 @@ function write_file_cb(buff::Ptr{UInt8}, sz::Csize_t, n::Csize_t, p_wd::Ptr{Void
nbytes::Csize_t
end

c_write_file_cb = cfunction(write_file_cb, Csize_t, (Ptr{UInt8}, Csize_t, Csize_t, Ptr{Void}))
c_write_file_cb = cfunction(write_file_cb, Csize_t, Tuple{Ptr{UInt8}, Csize_t, Csize_t, Ptr{Nothing}})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The deprecation warning is a bit misleading. For C calls you should use Cvoid. That's usually the case when you do Ptr{Void}.

@testset "conn error" begin
# check connection error
@test_throws FTPClientError FTP(hostname="not a host", username=username(server), password=password(server), ssl=false)
end
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you just add @testsets here? Or are there other changes I should look for?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As far as I can tell, adding @testsets was the only change here

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed

@@ -1,6 +1,8 @@
using Compat
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should set the minimum required version of Compat to v0.41 (in the REQUIRE file). This is the first version of Compat that includes Nothing and Cvoid.

src/FTPC.jl Outdated
@@ -113,7 +115,7 @@ end
# Callbacks
##############################

function write_file_cb(buff::Ptr{UInt8}, sz::Csize_t, n::Csize_t, p_wd::Ptr{Void})
function write_file_cb(buff::Ptr{UInt8}, sz::Csize_t, n::Csize_t, p_wd::Ptr{Nothing})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since you're just C calls here you should be using Ptr{Cvoid} instead of Ptr{Nothing}. Details in the Julia NEWS

Void has been renamed back to Nothing with an alias Cvoid for use when calling C with a return type of Cvoid or a return or argument type of Ptr{Cvoid} (#25162).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

src/FTPObject.jl Outdated
retry_wait_seconds::Integer = 5
)

successful_delivery = Vector{Bool}()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could be written simply as successful_delivery = Bool[]

attempts += 1
end

push!(successful_delivery, file_delivery_success)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe just return file_delivery_success. Then you can have successful_delivery = open(...) above

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure what your suggestion is here. The function is attempting to upload multiple files so returns successful_delivery, a vector of booleans that indicate if the file was successfully delivered.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I stand corrected. I double checked this but I missed the for loop. Sorry for the noise

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

REQUIRE Outdated
@@ -1,3 +1,3 @@
julia 0.6
LibCURL 0.2.2
Compat 0.8.3
Compat 0.41-
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just Compat 0.41 is good here

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I should reword the above to be:

This should be changed to be Compat 0.41

Copy link
Contributor

@omus omus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Next time we should keep separate these as separate PRs to make it easier to review.

@omus
Copy link
Contributor

omus commented Jan 22, 2018

Feel free to make a merge commit whenever. Avoid using squash and merge here as there are two distinct authors.

@kano31 kano31 merged commit 1cb797b into master Jan 22, 2018
@kano31 kano31 deleted the upload_with_retry branch January 22, 2018 21:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants