@@ -6,12 +6,14 @@ use thiserror::Error;
6
6
7
7
use mithril_common:: {
8
8
entities:: Snapshot ,
9
- messages:: { SnapshotListItemMessage , SnapshotListMessage , SnapshotMessage } ,
9
+ messages:: { SnapshotListItemMessage , SnapshotListMessage , SnapshotMessage , ToMessageAdapter } ,
10
10
StdResult ,
11
11
} ;
12
12
13
- use crate :: aggregator_client:: AggregatorClient ;
14
13
use crate :: utils:: DownloadProgressReporter ;
14
+ use crate :: {
15
+ aggregator_client:: AggregatorClient , message_adapters:: ToSnapshotDownloadMessageAdapter ,
16
+ } ;
15
17
16
18
/// Error for the Snapshot client
17
19
#[ derive( Error , Debug ) ]
@@ -77,7 +79,9 @@ impl SnapshotClient {
77
79
{
78
80
Ok ( ( ) ) => {
79
81
// the snapshot download does not fail if the statistic call fails.
80
- let _ = self . add_statistics ( snapshot) . await ;
82
+ if let Err ( e) = self . add_statistics ( snapshot) . await {
83
+ warn ! ( "Could not POST snapshot download statistics: {e:?}" ) ;
84
+ }
81
85
82
86
Ok ( ( ) )
83
87
}
@@ -101,7 +105,8 @@ impl SnapshotClient {
101
105
/// Increments Aggregator's download statistics
102
106
pub async fn add_statistics ( & self , snapshot : & Snapshot ) -> StdResult < ( ) > {
103
107
let url = "statistics/snapshot" ;
104
- let json = serde_json:: to_string ( snapshot) ?;
108
+ let snapshot_download_message = ToSnapshotDownloadMessageAdapter :: adapt ( snapshot) ;
109
+ let json = serde_json:: to_string ( & snapshot_download_message) ?;
105
110
let _response = self . http_client . post_content ( url, & json) . await ?;
106
111
107
112
Ok ( ( ) )
0 commit comments