[前][次][番号順一覧][スレッド一覧]

ruby-changes:13728

From: shugo <ko1@a...>
Date: Wed, 28 Oct 2009 13:12:04 +0900 (JST)
Subject: [ruby-changes:13728] Ruby:r25519 (trunk): * lib/net/ftp.rb (Net::FTP#initialize): sets @binary to true.

shugo	2009-10-28 13:09:20 +0900 (Wed, 28 Oct 2009)

  New Revision: 25519

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=25519

  Log:
    * lib/net/ftp.rb (Net::FTP#initialize): sets @binary to true.
    * lib/net/ftp.rb (Net::FTP#binary=): sends a TYPE command only when
      logged in. [ruby-dev:39548]
    * lib/net/ftp.rb (Net::FTP#send_type_command): new private method
      which sends an appropriate TYPE command according to the value of
      @binary.
    * lib/net/ftp.rb (Net::FTP#login): calls send_type_command instead
      of binary=.

  Modified files:
    trunk/ChangeLog
    trunk/lib/net/ftp.rb

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 25518)
+++ ChangeLog	(revision 25519)
@@ -1,3 +1,17 @@
+Wed Oct 28 13:02:10 2009  Shugo Maeda  <shugo@r...>
+
+	* lib/net/ftp.rb (Net::FTP#initialize): sets @binary to true.
+
+	* lib/net/ftp.rb (Net::FTP#binary=): sends a TYPE command only when
+	  logged in. [ruby-dev:39548]
+
+	* lib/net/ftp.rb (Net::FTP#send_type_command): new private method
+	  which sends an appropriate TYPE command according to the value of
+	  @binary.
+
+	* lib/net/ftp.rb (Net::FTP#login): calls send_type_command instead
+	  of binary=.
+
 Tue Oct 27 22:46:44 2009  NARUSE, Yui  <naruse@r...>
 
 	* lib/net/ftp.rb (Net::FTP#initialize): @sock = nil.
Index: lib/net/ftp.rb
===================================================================
--- lib/net/ftp.rb	(revision 25518)
+++ lib/net/ftp.rb	(revision 25519)
@@ -128,11 +128,12 @@
     #
     def initialize(host = nil, user = nil, passwd = nil, acct = nil)
       super()
-      @binary = false
+      @binary = true
       @passive = false
       @debug_mode = false
       @resume = false
       @sock = nil
+      @logged_in = false
       if host
 	connect(host)
 	if user
@@ -144,10 +145,19 @@
     def binary=(newmode)
       if newmode != @binary
         @binary = newmode
-        @binary ? voidcmd("TYPE I") : voidcmd("TYPE A") unless closed?
+        send_type_command if @logged_in
       end
     end
 
+    def send_type_command
+      if @binary
+        voidcmd("TYPE I")
+      else
+        voidcmd("TYPE A")
+      end
+    end
+    private :send_type_command
+
     def with_binary(newmode)
       oldmode = binary
       self.binary = newmode
@@ -393,7 +403,8 @@
 	raise FTPReplyError, resp
       end
       @welcome = resp
-      self.binary = true
+      send_type_command
+      @logged_in = true
     end
 
     #

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]