File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -239,6 +239,12 @@ enum Commands {
239239 #[ arg( trailing_var_arg = true ) ]
240240 extra : Vec < String > ,
241241 } ,
242+ /// List all files referenced in the journal with their reference counts
243+ Files {
244+ journal : String ,
245+ #[ arg( trailing_var_arg = true ) ]
246+ extra : Vec < String > ,
247+ } ,
242248 /// Recursively list all files in a directory which are not referenced in the journal
243249 UnusedFiles {
244250 directory : String ,
@@ -700,6 +706,23 @@ fn main() -> Result<()> {
700706 }
701707 }
702708
709+ Commands :: Files { journal, extra } => {
710+ let journal_paths = collect_paths ( & journal, & extra) ;
711+ let ledger = load_and_verify ( & journal_paths) ?;
712+
713+ let mut file_counts: std:: collections:: BTreeMap < & str , usize > =
714+ std:: collections:: BTreeMap :: new ( ) ;
715+ for tx in & ledger. transactions {
716+ for f in & tx. files {
717+ * file_counts. entry ( f. as_str ( ) ) . or_insert ( 0 ) += 1 ;
718+ }
719+ }
720+
721+ for ( file, count) in & file_counts {
722+ println ! ( "{count} {file}" ) ;
723+ }
724+ }
725+
703726 Commands :: UnusedFiles {
704727 directory,
705728 journal,
You can’t perform that action at this time.
0 commit comments