@@ -27,8 +27,12 @@ pub fn show_brief_version_list(
2727 sort_recent_first : bool ,
2828 w : & mut dyn Write
2929) -> Result < ( ) > {
30- for info in get_band_infos ( archive, sort_recent_first) ? {
31- writeln ! ( w, "{}" , info. id) ?
30+ let mut band_ids = archive. list_band_ids ( ) ?;
31+ if sort_recent_first {
32+ band_ids. reverse ( ) ;
33+ }
34+ for band_id in band_ids {
35+ writeln ! ( w, "{}" , band_id) ?
3236 }
3337 Ok ( ( ) )
3438}
@@ -39,8 +43,25 @@ pub fn show_verbose_version_list(
3943 show_sizes : bool ,
4044 w : & mut dyn Write ,
4145) -> Result < ( ) > {
42- for info in get_band_infos ( archive, sort_recent_first) ? {
43- let band_id = & info. id ;
46+ let mut band_ids = archive. list_band_ids ( ) ?;
47+ if sort_recent_first {
48+ band_ids. reverse ( ) ;
49+ }
50+ for band_id in band_ids {
51+ let band = match Band :: open ( & archive, & band_id) {
52+ Ok ( band) => band,
53+ Err ( e) => {
54+ ui:: problem ( & format ! ( "Failed to open band {:?}: {:?}" , band_id, e) ) ;
55+ continue ;
56+ }
57+ } ;
58+ let info = match band. get_info ( ) {
59+ Ok ( info) => info,
60+ Err ( e) => {
61+ ui:: problem ( & format ! ( "Failed to read band tail {:?}: {:?}" , band_id, e) ) ;
62+ continue ;
63+ }
64+ } ;
4465 let is_complete_str = if info. is_closed {
4566 "complete"
4667 } else {
@@ -93,28 +114,3 @@ pub fn show_entry_names<E: Entry, I: Iterator<Item = E>>(it: I, w: &mut dyn Writ
93114 }
94115 Ok ( ( ) )
95116}
96-
97- fn get_band_infos ( archive : & Archive , sort_recent_first : bool ) -> Result < Vec < band:: Info > > {
98- let mut band_infos = vec ! [ ] ;
99- for band_id in archive. list_band_ids ( ) ? {
100- let band = match Band :: open ( & archive, & band_id) {
101- Ok ( band) => band,
102- Err ( e) => {
103- ui:: problem ( & format ! ( "Failed to open band {:?}: {:?}" , band_id, e) ) ;
104- continue ;
105- }
106- } ;
107- let info = match band. get_info ( ) {
108- Ok ( info) => info,
109- Err ( e) => {
110- ui:: problem ( & format ! ( "Failed to read band tail {:?}: {:?}" , band_id, e) ) ;
111- continue ;
112- }
113- } ;
114- band_infos. push ( info) ;
115- }
116- if sort_recent_first {
117- band_infos. sort_unstable_by_key ( |info| std:: cmp:: Reverse ( info. start_time ) ) ;
118- }
119- Ok ( band_infos)
120- }
0 commit comments