Commit c2d703b New function to compute file list stats.

1 file Authored and Committed by tibbs 3 months ago
New function to compute file list stats.

    
 1 @@ -14,6 +14,9 @@
 2   # ZSHISM? newline for IFS.
 3   IFS=$'\n'
 4   
 5 + # Declare globals
 6 + typeset -A tcounts   # Transfer counts
 7 + 
 8   # Do this very early
 9   starttime=$(date +%s)
10   
11 @@ -1027,6 +1030,47 @@
12       logit l "Generating database diff end: $mod"
13   }
14   
15 + compute_file_list_stats () {
16 +     # Calculate and log counts of the various generated lists
17 +     local mod=$1
18 +     local -a stats
19 +     stats=(allfiles alldirs newfiles newdirs changedpaths localfiles \
20 +         localdirs deletefiles deletedirs missingfiles missingdirs \
21 +         updatedfiles updatetimestamps checksumfailed)
22 + 
23 +     for i in stats; do
24 +         counts[$i]=0
25 +         [[ -f $i-$mod ]] && counts[$i]=$(wc -l < $i-$mod)
26 +     done
27 + 
28 +     counts[totaltransfer]=$(wc -l transferlist-$mod)
29 + 
30 +     # Until the rest of the code is fixed up
31 +     counts[extrafiles]=$counts[deletefiles]
32 +     counts[extradirs]=$counts[deletedirs]
33 +     counts[sizechanged]=$counts[updatedfiles]
34 +     counts[allserverfiles]=$counts[allfiles]
35 +     counts[allserverdirs]=$counts[alldirs]
36 +     counts[newserverfiles]=$counts[newfiles]
37 +     counts[newserverdirs]=$counts[newdirs]
38 + 
39 +     # Previously these two were printed before generating the local file lists
40 +     db2f "Total on server:       %7d files, %4d dirs.\n" $cntallserverfiles $cntallserverdirs
41 +     db2f "New on server:         %7d files, %4d dirs.\n" $cntnewserverfiles $cntnewserverdirs
42 + 
43 +     db2f "Total on client:       %7d files, %4d dirs.\n" $counts[localfiles $counts[localdirs]
44 +     db2f "Not present on server: %7d files, %4d dirs.\n" $counts[extrafiles] $counts[extradirs]
45 +     db2f "Missing on client:     %7d files, %4d dirs.\n" $counts[missingfiles] $counts[missingdirs]
46 +     db2f "Size Changed:          %7d files.\n" $counts[sizechanged]
47 +     db2f "Timestamps to restore: %7d files.\n" $counts[updatetimestamps]
48 +     db2f "Checksum Failed:       %7d files.\n" $counts[checksumfailed]
49 +     db2f "Filelist changes:      %7d paths.\n" $counts[changedpaths]
50 +     db2f "Total to transfer:     %7d paths.\n" $counts[totaltransfer]
51 + 
52 +     logit L "Counts for $mod: Svr:$counts[allserverfiles]/$counts[allserverdirs] Loc:$counts[localfiles]/$counts[localdirs] Diff:$counts[changedpaths] New:$counts[newserverfiles]/$counts[newserverdirs] Xtra:$counts[extrafiles]/$counts[extradirs] Miss:$counts[missingfiles]/$counts[missingdirs] Size:$counts[sizechanged] Csum:$counts[checksumfailed] Dtim:$counts[updatetimestamps]"
53 + 
54 + }
55 + 
56   generate_local_file_list () {
57       # Generate lists of what the client has.
58       local mod=$1