-
Notifications
You must be signed in to change notification settings - Fork 36
Open
Description
The command SIZE is calling read method of the file driver. Which is bad in the case your driver is not a file system.
For example, I ftpd with google bucket and it works perfectly except for this command.
For informations, we monkey-patched the method internally for our tool, like that:
( PS: I'm not gonna open a pull request as it's not just debugging feature, and better idea of implementation would exists )
# frozen_string_literal: true
require_relative 'command_handler'
module Ftpd
class CmdSize < CommandHandler
def cmd_size(path)
ensure_logged_in
ensure_file_system_supports :read
syntax_error unless path
path = File.expand_path(path, name_prefix)
ensure_accessible(path)
ensure_exists(path)
if file_system.respond_to?(:size)
size = file_system.size(path, data_type).to_i
reply "213 #{size}"
else
file_system.read(path) do |file|
if data_type == 'A'
output = StringIO.new
io = Ftpd::Stream.new(output, data_type)
io.write(file)
size = output.size
else
size = file.size
end
reply "213 #{size}"
end
end
end
end
endMetadata
Metadata
Assignees
Labels
No labels