Skip to content

Longname causes hard crash if mtime attr isn't set. #146

@SamODonnell89

Description

@SamODonnell89

Ran into a case where a client's SFTP server had files and folders with no attributes set for mtime, createtime etc. This causes a hard crash TypeError (can't convert nil into an exact number)

Tried to create a PR to resolve this but received a 403 when trying to push.

name.rb

longname << Time.at(attributes.mtime || 0).strftime("%b %e %H:%M ")

test_name.rb

@directory_no_mtime = Net::SFTP::Protocol::V04::Name.new("test", Net::SFTP::Protocol::V04::Attributes.new(:type => 2, :mtime => nil, :owner => "jamis", :group => "users", :size => 1024, :permissions => 0755))
...

def test_longname_should_fallback_to_time_at_0_if_mtime_is_nil
    assert_equal "drwxr-xr-x jamis    users        1024 Jan  1 00:00 test",
      @directory_no_mtime.longname
end

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions