forked from hachi/MogileFS-Utils
-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding simple mogrename utility script that allows for renaming file (key) form an old key to a new key easily. Signed-off-by: Krzysztof Wilczynski <[email protected]>
- Loading branch information
1 parent
93c53d7
commit 8d1c1ae
Showing
4 changed files
with
83 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,15 @@ | ||
2.21 -- 2011-12-16 | ||
|
||
* Add "mogrename" utility script (kwilczynski, Krzysztof Wilczynski). | ||
|
||
2.21 -- 2011-10-29 | ||
|
||
* Improve error handling for broken usage files in `mogadm check` | ||
|
||
2.20 -- 2011-06-15 | ||
|
||
* Remove redundant tracker calls. Required for MogileFS::Server 2.50 as | ||
the redundant commands are now cached harder. | ||
the redundant commands are now cached harder. | ||
(dormando <[email protected]>) | ||
|
||
2.19 -- 2011-01-08 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,3 +13,4 @@ mogfileinfo | |
moglistfids | ||
moglistkeys | ||
mogfiledebug | ||
mogrename |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
#!/usr/bin/perl | ||
|
||
=head1 NAME | ||
mogrename -- Rename file (key) from one key to another | ||
=head1 SYNOPSIS | ||
$ mogrename [OPTIONS] --old-key='/hello.jpg' --new-key='/bye.jpg' | ||
$ mogupload --trackers=host --domain=foo --class=bar \ | ||
--old-key='/hello.jpg' --new-key='/bye.jpg' | ||
$ mogupload --trackers=host1:7001,host2:7001 --domain=foo --class=bar \ | ||
--old-key='/hello.jpg' --new-key='/bye.jpg' | ||
=head1 OPTIONS | ||
=over | ||
=item --trackers=host1:7001,host2:7001 | ||
Use these MogileFS trackers to negotiate with. | ||
=item --domain=<domain> | ||
Set the MogileFS domain to use. | ||
=item --class=<class> | ||
Set the class to use. Will use default class if not specified. | ||
=item --old-key='<old key>' | ||
An old key to rename the file from. Can be an arbitrary string. | ||
=item --new-key='<new key>' | ||
A new key to rename the file to. Can be an arbitrary string. | ||
=back | ||
=head1 AUTHOR | ||
Krzysztof Wilczynski E<lt>L<[email protected]>E<gt> | ||
=head1 BUGS | ||
None for this release. Please report any issues found. | ||
=head1 LICENSE | ||
Licensed for use and redistribution under the same terms as Perl itself. | ||
=cut | ||
|
||
use strict; | ||
use warnings; | ||
|
||
use lib './lib'; | ||
use MogileFS::Utils; | ||
|
||
my $utils = MogileFS::Utils->new; | ||
|
||
my $usage = "--trackers=host --domain=foo --class=bar " | ||
. "--old-key='/hello.jpg' --new-key='/bye.jpg'"; | ||
|
||
my $options = $utils->getopts($usage, qw(old-key=s new-key=s)); | ||
|
||
my $mogile_client = $utils->client; | ||
|
||
$mogile_client->rename($options->{'old-key'}, $options->{'new-key'}); | ||
|
||
if ($mogile_client->errcode) { | ||
die "Error renaming file (key) from " . $mogile_client->errstr; | ||
} |