Skip to content

undefined method 'size' for nil (NoMethodError) on TIME_PARSER if MDTM command returns something different than a 213 response #66

@pitbulk

Description

@pitbulk

When

resp = sendcmd("MDTM #{filename}")

returns something different than 213. (E.g., 550 Not a plain file, 502 Command not implemented)

Then the method mdtm

def mdtm(filename)
  resp = sendcmd("MDTM #{filename}")
  if resp.start_with?("213")
    return get_body(resp)
  end
  #
end

will return nil

and then the method mtime:

def mtime(filename, local = false)
  return TIME_PARSER.(mdtm(filename), local)
end

will raise an undefined method 'size' for nil (NoMethodError) on the TIME_PARSER, because value is nil

value = value[0, 97] + "..." if value.size > 100

Easy fix:

def mtime(filename, local = false)
  value = mdtm(filename)
  TIME_PARSER.(value, local) if value
end

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions