Ruby mogilefs-client dev/users discussion/patches/bugs/help/...
 help / color / Atom feed
* [PATCH 0/3] various updates
@ 2018-06-19  3:57 Eric Wong
  2018-06-19  3:57 ` [PATCH 1/3] mog: add updateclass command Eric Wong
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Eric Wong @ 2018-06-19  3:57 UTC (permalink / raw)
  To: mogilefs-client-public

Eric Wong (3):
      mog: add updateclass command
      socket/pure_ruby: favor String#clear if available
      fix indentation warnings with ruby trunk

 bin/mog                          |  5 +++++
 lib/mogilefs/backend.rb          |  4 ++--
 lib/mogilefs/copy_stream.rb      |  6 +++---
 lib/mogilefs/http_file.rb        | 22 +++++++++++-----------
 lib/mogilefs/socket/pure_ruby.rb |  2 +-
 5 files changed, 22 insertions(+), 17 deletions(-)

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 1/3] mog: add updateclass command
  2018-06-19  3:57 [PATCH 0/3] various updates Eric Wong
@ 2018-06-19  3:57 ` Eric Wong
  2018-06-19  3:57 ` [PATCH 2/3] socket/pure_ruby: favor String#clear if available Eric Wong
  2018-06-19  3:57 ` [PATCH 3/3] fix indentation warnings with ruby trunk Eric Wong
  2 siblings, 0 replies; 4+ messages in thread
From: Eric Wong @ 2018-06-19  3:57 UTC (permalink / raw)
  To: mogilefs-client-public; +Cc: Eric Wong

This is to change classes of existing files (not change classes
themselves as in "mogadm class update"
---
 bin/mog | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/bin/mog b/bin/mog
index 89b1b9b..6238289 100755
--- a/bin/mog
+++ b/bin/mog
@@ -160,6 +160,11 @@ def human_size(size)
         mg.get_file_data(key, $stdout)
       end
     end
+  when 'updateclass'
+    newclass = cfg[:class] or abort '-C/--class not specified'
+    ARGV.each do |key|
+      mg.updateclass(key, newclass)
+    end
   when 'ls'
     prefixes = ARGV.empty? ? [ nil ] : ARGV
     if ls_l
-- 
EW


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 2/3] socket/pure_ruby: favor String#clear if available
  2018-06-19  3:57 [PATCH 0/3] various updates Eric Wong
  2018-06-19  3:57 ` [PATCH 1/3] mog: add updateclass command Eric Wong
@ 2018-06-19  3:57 ` Eric Wong
  2018-06-19  3:57 ` [PATCH 3/3] fix indentation warnings with ruby trunk Eric Wong
  2 siblings, 0 replies; 4+ messages in thread
From: Eric Wong @ 2018-06-19  3:57 UTC (permalink / raw)
  To: mogilefs-client-public; +Cc: Eric Wong

String#replace keeps garbage around a bit longer,
so it's not always the better option.

cf. http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-core/86983
    https://public-inbox.org/ruby-core/20180511033641.GA4459@dcvr/
---
 lib/mogilefs/socket/pure_ruby.rb | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/mogilefs/socket/pure_ruby.rb b/lib/mogilefs/socket/pure_ruby.rb
index 59e43e1..acbbaca 100644
--- a/lib/mogilefs/socket/pure_ruby.rb
+++ b/lib/mogilefs/socket/pure_ruby.rb
@@ -42,7 +42,7 @@ def timed_peek(len, dst, timeout = 5)
     rescue Errno::EAGAIN
       wait(timeout) or unreadable_socket!(timeout)
     rescue EOFError
-      dst.replace("")
+      dst.respond_to?(:clear) ? dst.clear : dst.replace("")
       return
     end while true
   rescue EOFError
-- 
EW


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 3/3] fix indentation warnings with ruby trunk
  2018-06-19  3:57 [PATCH 0/3] various updates Eric Wong
  2018-06-19  3:57 ` [PATCH 1/3] mog: add updateclass command Eric Wong
  2018-06-19  3:57 ` [PATCH 2/3] socket/pure_ruby: favor String#clear if available Eric Wong
@ 2018-06-19  3:57 ` Eric Wong
  2 siblings, 0 replies; 4+ messages in thread
From: Eric Wong @ 2018-06-19  3:57 UTC (permalink / raw)
  To: mogilefs-client-public; +Cc: Eric Wong

Ruby trunk started warning about more mismatched indentations
starting around r62836.
---
 lib/mogilefs/backend.rb     |  4 ++--
 lib/mogilefs/copy_stream.rb |  6 +++---
 lib/mogilefs/http_file.rb   | 22 +++++++++++-----------
 3 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/lib/mogilefs/backend.rb b/lib/mogilefs/backend.rb
index 7f91508..6d5fe17 100644
--- a/lib/mogilefs/backend.rb
+++ b/lib/mogilefs/backend.rb
@@ -335,8 +335,8 @@ def clear_cache(types = %w(all))
       end
     end
     nil
-    ensure
-      sockets.each { |io| io.close }
+  ensure
+    sockets.each { |io| io.close }
   end
 
   # Returns a socket connected to a MogileFS tracker.
diff --git a/lib/mogilefs/copy_stream.rb b/lib/mogilefs/copy_stream.rb
index f50bf08..202b2e3 100644
--- a/lib/mogilefs/copy_stream.rb
+++ b/lib/mogilefs/copy_stream.rb
@@ -23,8 +23,8 @@ def self.copy_stream(src, dst)
     end
     dst_io.flush if dst_io.respond_to?(:flush)
     written
-    ensure
-      src_io.close if src.respond_to?(:to_str)
-      dst_io.close if dst.respond_to?(:to_str)
+  ensure
+    src_io.close if src.respond_to?(:to_str)
+    dst_io.close if dst.respond_to?(:to_str)
   end
 end
diff --git a/lib/mogilefs/http_file.rb b/lib/mogilefs/http_file.rb
index a58801a..aa0bcf2 100644
--- a/lib/mogilefs/http_file.rb
+++ b/lib/mogilefs/http_file.rb
@@ -83,11 +83,11 @@ def put_streaming_io(sock, uri) # unlikely to be used
 
   def rewind_or_raise!(uri, err)
     @active.rewind if @active
-    rescue => e
-      msg = "#{uri} failed with #{err.message} (#{err.class}) and " \
-            "retrying is impossible as rewind on " \
-            "#{@active.inspect} failed with: #{e.message} (#{e.class})"
-      raise NonRetryableError, msg, e.backtrace
+  rescue => e
+    msg = "#{uri} failed with #{err.message} (#{err.class}) and " \
+          "retrying is impossible as rewind on " \
+          "#{@active.inspect} failed with: #{e.message} (#{e.class})"
+    raise NonRetryableError, msg, e.backtrace
   end
 
   ##
@@ -127,12 +127,12 @@ def upload(devid, uri) # :nodoc:
 
     read_response(sock) # raises on errors
     file_size
-    rescue SystemCallError, RetryableError => err
-      rewind_or_raise!(uri, err)
-      raise
-    ensure
-      file.close if file && @big_io != file
-      sock.close if sock
+  rescue SystemCallError, RetryableError => err
+    rewind_or_raise!(uri, err)
+    raise
+  ensure
+    file.close if file && @big_io != file
+    sock.close if sock
   end
 
   def nhp_put(devid, uri)
-- 
EW


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, back to index

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-06-19  3:57 [PATCH 0/3] various updates Eric Wong
2018-06-19  3:57 ` [PATCH 1/3] mog: add updateclass command Eric Wong
2018-06-19  3:57 ` [PATCH 2/3] socket/pure_ruby: favor String#clear if available Eric Wong
2018-06-19  3:57 ` [PATCH 3/3] fix indentation warnings with ruby trunk Eric Wong

Ruby mogilefs-client dev/users discussion/patches/bugs/help/...

Archives are clonable:
	git clone --mirror https://yhbt.net/mogilefs-client-public
	git clone --mirror http://ou63pmih66umazou.onion/mogilefs-client-public

Example config snippet for mirrors

Newsgroups are available over NNTP:
	nntp://news.public-inbox.org/inbox.comp.file-systems.mogilefs.ruby
	nntp://ou63pmih66umazou.onion/inbox.comp.file-systems.mogilefs.ruby

 note: .onion URLs require Tor: https://www.torproject.org/

AGPL code for this site: git clone https://public-inbox.org/public-inbox.git