From d2c3306bf731e37b4ff05c7790df6434ee326afe Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Thu, 17 Nov 2011 09:57:48 +0000 Subject: [PATCH] mog: improve "stat" subcommand * return error if there was a missing key * use file_info to help us determine info * show all URLs for a given key --- bin/mog | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/bin/mog b/bin/mog index af50eb7..15fa88d 100755 --- a/bin/mog +++ b/bin/mog @@ -169,18 +169,24 @@ begin mg.rename(from, to) when 'stat' # this outputs a RFC822-like format ARGV.empty? and raise ArgumentError, ' []' - ARGV.each do |key| - if size = mg.size(key) + ok = true + ARGV.each_with_index do |key,j| + begin + info = mg.file_info(key) puts "Key: #{key}" - puts "Size: #{size}" - mg.get_paths(key).each_with_index do |path,i| + puts "Size: #{info['length']}" + puts "Class: #{info['class']}" + o = { :pathcount => info["devcount"] } + mg.get_paths(key, o).each_with_index do |path,i| puts "URL-#{i}: #{path}" end - puts "" - else + puts "" if ARGV.size != (j + 1) + rescue MogileFS::Backend::UnknownKeyError warn "No such key: #{key}" + ok = false end end + exit(ok) when 'tee' require 'tempfile' dkey = ARGV.shift or raise ArgumentError, '' -- 2.11.4.GIT