projects
/
cumulus.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
1ac0c45
)
Update restore.pl for new snapshot format (v0.8).
author
Michael Vrable
<mvrable@cs.ucsd.edu>
Wed, 30 Jul 2008 18:48:45 +0000
(11:48 -0700)
committer
Michael Vrable
<mvrable@turin.ucsd.edu>
Wed, 30 Jul 2008 18:48:45 +0000
(11:48 -0700)
contrib/restore.pl
patch
|
blob
|
history
diff --git
a/contrib/restore.pl
b/contrib/restore.pl
index
98ae277
..
0af9dea
100755
(executable)
--- a/
contrib/restore.pl
+++ b/
contrib/restore.pl
@@
-122,17
+122,21
@@
sub load_ref {
# If a range was specified, then only a subset of the bytes of the object
# are desired. Extract just the desired bytes.
if ($range) {
# If a range was specified, then only a subset of the bytes of the object
# are desired. Extract just the desired bytes.
if ($range) {
- if ($range !~ m/^\[((\d+)\+)?(\d+)\]$/) {
- die "Malformed object range: $range";
- }
-
my $object_size = length $contents;
my ($start, $length);
my $object_size = length $contents;
my ($start, $length);
- if (defined($1)) {
- ($start, $length) = ($2 + 0, $3 + 0);
- } else {
+
+ if ($range =~ m/^\[=(\d+)\]$/) {
+ die "Object size incorrect (ref $ref_str, actual size $object_size"
+ if $object_size != $1;
+ ($start, $length) = (0, $1 + 0);
+ } elsif ($range =~ m/^\[(\d+)\]$/) {
($start, $length) = (0, $3 + 0);
($start, $length) = (0, $3 + 0);
+ } elsif ($range =~ m/^\[(\d+)\+(\d+)\]$/) {
+ ($start, $length) = ($1 + 0, $2 + 0);
+ } else {
+ die "Malformed object range: $range";
}
}
+
if ($start >= $object_size || $start + $length > $object_size) {
die "Object range $range falls outside object bounds "
. "(actual size $object_size)";
if ($start >= $object_size || $start + $length > $object_size) {
die "Object range $range falls outside object bounds "
. "(actual size $object_size)";