diff options
author | Eric Wong <normalperson@yhbt.net> | 2011-11-08 01:53:06 +0000 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2011-11-08 01:53:06 +0000 |
commit | fd5098ba0825d5ee603265a40e8c62b97191b7b6 (patch) | |
tree | 6505d865bfd2c5db1000b31c7d3bb2ed87892d75 /lib/mogilefs/mogilefs.rb | |
parent | 088d88332564a5d09cf8a57695a53453ab59f686 (diff) | |
download | mogilefs-client-fd5098ba0825d5ee603265a40e8c62b97191b7b6.tar.gz |
This is a command added in MogileFS 2.45
Diffstat (limited to 'lib/mogilefs/mogilefs.rb')
-rw-r--r-- | lib/mogilefs/mogilefs.rb | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/lib/mogilefs/mogilefs.rb b/lib/mogilefs/mogilefs.rb index 97e07e2..ef01f5b 100644 --- a/lib/mogilefs/mogilefs.rb +++ b/lib/mogilefs/mogilefs.rb @@ -218,4 +218,19 @@ class MogileFS::MogileFS < MogileFS::Client [ keys, res['next_after'] ] end + + # Used to return metadata about a file. Returns the domain, class, expected + # length, devcount, etc. Optionally device ids (not paths) can be returned as + # well if :devices is specified. + # + # Should be used for informational purposes, and not usually for dynamically + # serving files. + def file_info(key, args = nil) + opts = { :domain => @domain, :key => key } + args and devices = args[:devices] and opts[:devices] = devices ? 1 : 0 + rv = @backend.file_info(opts) + %w(fid length devcount).each { |f| rv[f] = rv[f].to_i } + devids = rv["devids"] and rv["devids"] = devids.split(/,/).map! { |x| x.to_i } + rv + end end |