summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSean Whitton <spwhitton@spwhitton.name>2020-03-23 17:01:30 -0700
committerSean Whitton <spwhitton@spwhitton.name>2020-03-23 17:01:30 -0700
commitba87ebd4ffed0667d0f8600fe54d005e056710b8 (patch)
tree9d0643c0b1617789b3d4f1d295e171377a21078d
parent9c43d14b9e1f670404f8b5b121632edc0bee373e (diff)
downloadp5-Git-Annex-ba87ebd4ffed0667d0f8600fe54d005e056710b8.tar.gz
annex-review-unused: Check whether unused files still exist earlier
Signed-off-by: Sean Whitton <spwhitton@spwhitton.name>
-rw-r--r--Changes2
-rw-r--r--lib/App/annex_review_unused.pm46
2 files changed, 26 insertions, 22 deletions
diff --git a/Changes b/Changes
index 7837fcd..a68a8f1 100644
--- a/Changes
+++ b/Changes
@@ -1,6 +1,8 @@
Revision history for Git::Annex
{{$NEXT}}
+ - annex-review-unused: Check whether unused files still exist earlier.
+ Avoids misleading output when --just-print is supplied.
0.005 2020-03-23 11:55:48-07:00 America/Phoenix
- annex-review-unused: Add missing prompt_yn subroutine.
diff --git a/lib/App/annex_review_unused.pm b/lib/App/annex_review_unused.pm
index eae6cd0..4e6bb47 100644
--- a/lib/App/annex_review_unused.pm
+++ b/lib/App/annex_review_unused.pm
@@ -67,7 +67,28 @@ sub main {
$unused_opts{used_refspec} = $used_refspec_arg if $used_refspec_arg;
my @to_drop;
- my @unused_files = @{ $annex->unused(%unused_opts, log => 1) };
+ my @unused_files = grep {
+ # check the unused file still exists i.e. has not been dropped
+ # already (in the case of reviewing unused files at a remote,
+ # just check that it's not been dropped according to the local
+ # git-annex branch by using readpresentkey rather than
+ # checkpresentkey)
+
+ my $ret = $_->{contentlocation}
+ = $annex->abs_contentlocation($_->{key});
+
+ if ($from_arg) {
+ #<<<
+ try {
+ $annex->annex->readpresentkey($_->{key}, $uuid);
+ } catch {
+ $ret = 0;
+ };
+ #>>>
+ }
+
+ $ret;
+ } $annex->unused(%unused_opts, log => 1)->@*;
exit unless @unused_files;
if ($just_print) {
_say_spaced_bullet("There are unused files you can drop with"
@@ -77,27 +98,8 @@ sub main {
}
my $i = 0;
UNUSED: while ($i < @unused_files) {
- my $unused_file = $unused_files[$i];
-
- # check the unused file still exists i.e. has not been dropped
- # already (in the case of reviewing unused files at a remote, just
- # check that it's not been dropped according to the local
- # git-annex branch by using readpresentkey rather than
- # checkpresentkey)
- my $contentlocation = $annex->abs_contentlocation($unused_file->{key});
- if ($from_arg) {
- #<<<
- try {
- $annex->annex->readpresentkey($unused_file->{key}, $uuid);
- } catch {
- splice @unused_files, $i, 1;
- next UNUSED;
- };
- #>>>
- } elsif (!$contentlocation) {
- splice @unused_files, $i, 1;
- next UNUSED;
- }
+ my $unused_file = $unused_files[$i];
+ my $contentlocation = $unused_file->{contentlocation};
system qw(clear -x) unless $just_print;
_say_bold("unused file #" . $unused_file->{number} . ":");