Just code style. Rest of project uses style:<div><br></div><div> } else {</div><div><br></div><div>Braces on same line.</div><div><br></div><div>Also, no need for explicit string concat here:</div><div><br></div><div>
<span class="Apple-style-span" style="border-collapse: collapse; "> die "nothing found matching '" . $self->{prefix} . "'.\n";</span><br></div><div><span class="Apple-style-span" style="border-collapse: collapse;"><br>
</span></div><div><span class="Apple-style-span" style="border-collapse: collapse;">Just interoplate it. The ifs are very C-ish too. You could just do:</span></div><div><span class="Apple-style-span" style="border-collapse: collapse;"><br>
</span></div><div><span class="Apple-style-span" style="border-collapse: collapse;">die "Nothing found matching $self->{prefix}.\n" if $self->{prefix};</span></div><div><span class="Apple-style-span" style="border-collapse: collapse;">die "Nothing found to restore. (empty .meta file?)\n";</span></div>
<div><span class="Apple-style-span" style="border-collapse: collapse;"><br></span></div><div><span class="Apple-style-span" style="border-collapse: collapse;">(also note capitalized sentences in error messages.)</span></div>
<div><br><br><div class="gmail_quote">On Mon, Nov 3, 2008 at 1:49 AM, Gavin Carr <span dir="ltr"><<a href="mailto:gavin@openfusion.com.au">gavin@openfusion.com.au</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Here's a proposed patch to make brackup-restore complain if nothing is<br>
found to restore (probably most useful with --just, but works with --all<br>
as well.<br>
<br>
Any thoughts/comments/objections before I commit?<br>
<br>
Cheers,<br>
Gavin<br>
<br>
<br>
=== modified file 'lib/Brackup/Restore.pm'<br>
--- lib/Brackup/Restore.pm 2008-07-29 21:29:25 +0000<br>
+++ lib/Brackup/Restore.pm 2008-11-01 01:48:17 +0000<br>
@@ -71,6 +71,7 @@<br>
$self->{_target} = $target;<br>
$self->{_meta} = $meta;<br>
<br>
+ my $restore_count = 0;<br>
while (my $it = $parser->readline) {<br>
my $type = $it->{Type} || "f";<br>
die "Unknown filetype: type=$type, file: $it->{Path}" unless $type =~ /^[ldfp]$/;<br>
@@ -88,6 +89,7 @@<br>
}<br>
}<br>
<br>
+ $restore_count++;<br>
my $full = $self->{to} . "/" . $it->{Path};<br>
<br>
# restore default modes from header<br>
@@ -101,10 +103,21 @@<br>
$self->_restore_file ($full, $it) if $type eq "f";<br>
}<br>
<br>
- warn " * fixing stat info\n" if $self->{verbose};<br>
- $self->_exec_statinfo_updates;<br>
- warn " * done\n" if $self->{verbose};<br>
- return 1;<br>
+ if ($restore_count) {<br>
+ warn " * fixing stat info\n" if $self->{verbose};<br>
+ $self->_exec_statinfo_updates;<br>
+ warn " * done\n" if $self->{verbose};<br>
+ return 1;<br>
+ }<br>
+<br>
+ else {<br>
+ if ($self->{prefix}) {<br>
+ die "nothing found matching '" . $self->{prefix} . "'.\n";<br>
+ }<br>
+ else {<br>
+ die "nothing found to restore.\n";<br>
+ }<br>
+ }<br>
}<br>
<br>
sub _output_temp_filename {<br>
<br>
</blockquote></div><br></div>