-
Notifications
You must be signed in to change notification settings - Fork 897
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
Rewrite ftp file/directory existence and upload mechanisms to address a 550 error #1603
Conversation
cc @brandondunne @dajohnso |
super | ||
with_connection do |ftp| | ||
with_connection do |_ftp| |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you don't need it, then can you just remove the |_ftp|
entirely?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes
@jrafanie Looks great! 🍪 |
The creation of intermediate directories was removed in commit 32df530 as some ftp systems will allow you to create a directory without the intermediate directories. This commit is more conservative and assumes you must create each intermediate directory one at a time. file_exists? now encapsulates issuing ftp 'NLST' with exception handling on missing file/directories. create_directory_structure will now traverse the desired directory path and create missing intermediate directories. Move the actual uploading into a private method. net/ftp methods don't support Pathnames so convert them to Strings. https://bugzilla.redhat.com/show_bug.cgi?id=1184465
destination_file_exists? was renamed to file_exists? since it's used for the destination directories in addition to the destination file. destination_path needs to return a Pathname object that responds to join. https://bugzilla.redhat.com/show_bug.cgi?id=1184465
4b9529e
to
a49ae38
Compare
@Fryguy I rebased your ideas into the major commit:
|
Checked commits jrafanie@13ca633 .. jrafanie@a49ae38 with rubocop 0.27.1 vmdb/app/models/file_depot_ftp.rb
|
Rewrite ftp file/directory existence and upload mechanisms to address a 550 error
Added upstream ruby PR to enhance Net::FTP methods such as nlst to accept Pathname objects: ruby/ruby#828 |
Nice @jrafanie 👍 |
The creation of intermediate directories was removed in commit 32df530 as some ftp systems
will allow you to create a directory without the intermediate directories. Some ftp servers, including iis, don't support doing this and raise a 550 error on the first missing directory.
This pull request is more conservative and assumes you must create each intermediate directory one at a time.
https://bugzilla.redhat.com/show_bug.cgi?id=1184465
In a follow up pull request, I'll be adding camcorder tests to test the net/ftp interactions as the specs don't cover end to end testing.
The logging within FileDepotFtp was slightly changed.
Below is an example snippet when the ftp server doesn't have some of the intermediate directories: