From ba87ebd4ffed0667d0f8600fe54d005e056710b8 Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Mon, 23 Mar 2020 17:01:30 -0700 Subject: annex-review-unused: Check whether unused files still exist earlier Signed-off-by: Sean Whitton --- Changes | 2 ++ lib/App/annex_review_unused.pm | 46 ++++++++++++++++++++++-------------------- 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} . ":"); -- cgit v1.2.3 From ce6f40bde2492c6d6f7b33b7098712456c198269 Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Mon, 23 Mar 2020 17:01:41 -0700 Subject: add some parens to avoid perltidy inserting a spurious space Signed-off-by: Sean Whitton --- lib/App/annex_review_unused.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/App/annex_review_unused.pm b/lib/App/annex_review_unused.pm index 4e6bb47..dd2ed23 100644 --- a/lib/App/annex_review_unused.pm +++ b/lib/App/annex_review_unused.pm @@ -124,7 +124,7 @@ sub main { # before prompting, clear out stdin, to avoid # registered a keypress more than once ReadMode 4; - 1 while defined ReadKey -1; + 1 while defined ReadKey(-1); my @opts = ('y', 'n'); push @opts, 'o' if $contentlocation; -- cgit v1.2.3 From 15f16879f4400a7edabfc5fe22807bb195c860b3 Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Mon, 23 Mar 2020 17:02:19 -0700 Subject: bump version Signed-off-by: Sean Whitton --- dist.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dist.ini b/dist.ini index b7d27d0..1d52ed8 100644 --- a/dist.ini +++ b/dist.ini @@ -4,7 +4,7 @@ license = GPL_3 copyright_holder = Sean Whitton copyright_year = 2019-2020 -version = 0.005 +version = 0.006 [PkgVersion] [PodWeaver] -- cgit v1.2.3 From e5d36bfcae4b6d52747ea7815a08ed8392bcd07c Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Mon, 23 Mar 2020 17:03:11 -0700 Subject: v0.006 - annex-review-unused: Check whether unused files still exist earlier. Avoids misleading output when --just-print is supplied. Signed-off-by: Sean Whitton --- Changes | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Changes b/Changes index a68a8f1..a7995b0 100644 --- a/Changes +++ b/Changes @@ -1,6 +1,8 @@ Revision history for Git::Annex {{$NEXT}} + +0.006 2020-03-23 17:02:28-07:00 America/Phoenix - annex-review-unused: Check whether unused files still exist earlier. Avoids misleading output when --just-print is supplied. -- cgit v1.2.3