-
-
Notifications
You must be signed in to change notification settings - Fork 646
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
Automatically verify checksum after upload/download #92
Comments
@hgupta9 Want me to wrap this functionality into my work for #83? |
Sure, how do you plan on doing it? Could you make the API like this? For error handling For #83 - FtpError enum,
For checksum For #92 - FtpVerify enum,
For UploadFile/DownloadFile
The code to read the flags would be something like: bool verifyChecksum = ((verifyMode & FtpVerify.Checksum) == FtpVerify.Checksum) || ((verifyMode & FtpVerify.Retry) == FtpVerify.Retry);
bool verRetry = (verifyMode & FtpVerify.Retry) == FtpVerify.Retry;
bool verDelete = (verifyMode & FtpVerify.Delete) == FtpVerify.Delete;
bool verThrow = (verifyMode & FtpVerify.Throw) == FtpVerify.Throw; This is just a suggestion. You can use my comments for the enum properties. Do you have any better ideas? |
I hope your changes can be merged automatically since I have made substantial changes to the codebase, especially in FtpClient. |
As for the hashing, this should work: // If server supports the HASH command
if (client.HashAlgorithms != FtpHashAlgorithm.NONE) {
// Ask the server to compute the hash using whatever
// the default hash algorithm (probably SHA-1)
FtpHash hash = client.GetHash("/path/to/remote/somefile.ext");
// The FtpHash.Verify method computes the hash of the
// specified file or stream based on the hash algorithm
// the server computed its hash with.
if (hash.Verify("/path/to/local/somefile.ext")) {
// MATCH
}else{
// MISMATCH
}
} |
@jblacker Can you re-fork my version since I've just made significant changes to FtpClient and the async methods as well. |
@hgupta9 Yeah. I keep pulling your changes into my fork. Don't worry. Do you think it would be best to keep expanding the signature of should we create an Options object of some sort like a struct that contains all of the various optional settings? Something like:
|
Good point, but I would prefer you expand the signature. I just hate objects inside objects. Plus it allows users to clearly see what the function is capable of. Its still in beta and this time I'm introducing breaking changes in the API (thus the major version increment) so if it appears overbearing we can move to an object later. |
I should have a PR for you on this and #83 this weekend. |
@hgupta9 In order to implement the retry option, I added an |
What other features could they apply to? Upload/download? I dunno. Some times retrying does not improve reliability it only reduces performance, so I dunno. Maybe if we can test that retrying actually succeeds the 2nd time when it fails the first time. Start off with verification for now, maybe later it can be applied to other things, unless you know for a fact that retrying would benefit other features - then add them in I guess. |
@hgupta9 You're right, it's probably unnecessary at this point for any other failure type. |
UploadFile() and DownloadFile() should provide an arg to verify the checksum after upload/download is complete. Failure of hash match should:
The text was updated successfully, but these errors were encountered: