Fetching contributors…
Cannot retrieve contributors at this time
executable file 76 lines (47 sloc) 1.46 KB
=head1 NAME
mogfileinfo -- Fetch key metadata from a MogileFS installation
$ mogfileinfo --trackers=host --domain=foo --key="/hello.jpg"
=head1 OPTIONS
=item --trackers=host1:7001,host2:7001
Use these MogileFS trackers to negotiate with.
=item --domain=<domain>
Set the MogileFS domain to use.
=item --key="<key>"
The key to inspect. Can be an arbitrary string.
=head1 AUTHOR
Dormando E<lt>L<>E<gt>
=head1 BUGS
None known, but output might change in the future.
=head1 LICENSE
Licensed for use and redistribution under the same terms as Perl itself.
use strict;
use warnings;
use lib './lib';
use MogileFS::Utils;
my $util = MogileFS::Utils->new;
my $usage = "--trackers=host --domain=foo --key='/hello.jpg'";
my $c = $util->getopts($usage, 'key=s');
my $mogc = $util->client;
my $fid = $mogc->file_info($c->{key});
if ($mogc->errcode) {
die "Error fetching file info: " . $mogc->errstr;
die "Key not found: " . $c->{key} unless $fid;
# Might replace this with just fetching the devids from above...
my @paths = $mogc->get_paths($c->{key}, { noverify => 1, pathcount => 99 });
if ($mogc->errcode) {
die "Error fetching paths: " . $mogc->errstr;
die "No paths found or key does not exist" unless @paths;
print "- file: ", $c->{key}, "\n";
for my $item (sort keys %$fid) {
printf(" %8s: %20s\n", $item, $fid->{$item});
for my $path (@paths) {
print " - ", $path, "\n";