@@ -18,12 +18,14 @@ struct TransferHistoryDocument: FileDocument {
1818 results : record . results , includeModePlan : record . plannedFileCounts != nil )
1919 if asCSV {
2020 func quote ( _ value : String ) -> String { " \" " + value . replacingOccurrences ( of : " \" " , with : " \" \" " ) + " \" " }
21- let header = " source,destination,status,bytes,checksum,verification,transfer_state,transfer_summary,project,asc_mhl,client,reused \n "
21+ let header = " source,destination,status,bytes,checksum,verification,transfer_state,transfer_summary,project,asc_mhl,client,reused,recorded_status \n "
2222 let rows = record . results . map { row in
23- [ row . path , row . destinationPath ?? row . destination ?? " " , row . status , String ( row . size ) , row . checksum ?? " " ,
23+ [ row . path , row . destinationPath ?? row . destination ?? " " ,
24+ TransferHistoryResultPresentation . statusText ( for : row , mode : record . verificationMode ) ,
25+ String ( row . size ) , row . checksum ?? " " ,
2426 record . verificationMode . rawValue , record . state . rawValue , record . summary ,
2527 record . reportSettings . projectName , record . generateASCMHL ? " requested " : " not requested " ,
26- record . reportSettings . clientName , row . wasReused ? " true " : " false " ] . map ( quote ) . joined ( separator : " , " )
28+ record . reportSettings . clientName , row . wasReused ? " true " : " false " , row . status ] . map ( quote ) . joined ( separator : " , " )
2729 }
2830 func pair ( _ key : String , _ value : String ) -> String { quote ( key ) + " , " + quote ( value ) }
2931 func detail ( _ value : String ) -> String {
@@ -80,7 +82,7 @@ struct TransferHistoryDocument: FileDocument {
8082 let copyDurationSeconds : TimeInterval ?
8183 let verifyDurationSeconds : TimeInterval ?
8284 let performanceTelemetry : TransferPerformanceTelemetry ?
83- let results : [ ResultRow ]
85+ let results : [ HistoryResult ]
8486 }
8587 let encoder = JSONEncoder ( )
8688 encoder . outputFormatting = [ . prettyPrinted , . sortedKeys ]
@@ -96,7 +98,35 @@ struct TransferHistoryDocument: FileDocument {
9698 copyDurationSeconds : record . copyDurationSeconds ,
9799 verifyDurationSeconds : record . verifyDurationSeconds ,
98100 performanceTelemetry : record . performanceTelemetry ,
99- results : record . results ) )
101+ results : record . results . map { HistoryResult ( row : $0 , mode : record . verificationMode ) } ) )
100102 }
101103 }
102104}
105+
106+ /// Export the interpreted status without changing the saved journal row.
107+ /// `recordedStatus` retains old wording when it could overstate verification.
108+ private struct HistoryResult : Encodable {
109+ let id : UUID
110+ let path : String
111+ let status : String
112+ let recordedStatus : String ?
113+ let size : Int64
114+ let checksum : String ?
115+ let destination : String ?
116+ let destinationPath : String ?
117+ let clipIntegrity : ClipIntegrityFinding ?
118+ let wasReused : Bool ?
119+
120+ init ( row : ResultRow , mode : VerificationMode ) {
121+ id = row . id
122+ path = row . path
123+ status = TransferHistoryResultPresentation . statusText ( for : row , mode : mode )
124+ recordedStatus = status == row . status ? nil : row . status
125+ size = row . size
126+ checksum = row . checksum
127+ destination = row . destination
128+ destinationPath = row . destinationPath
129+ clipIntegrity = row . clipIntegrity
130+ wasReused = row . wasReused ? true : nil
131+ }
132+ }
0 commit comments