File tree Expand file tree Collapse file tree 2 files changed +6
-10
lines changed Expand file tree Collapse file tree 2 files changed +6
-10
lines changed Original file line number Diff line number Diff line change @@ -349,8 +349,8 @@ impl Worker {
349349 // time elapsed since the last save.
350350 match self . last_index_backup {
351351 Some ( last) if last. elapsed ( ) >= MINIMUM_DELAY_BETWEEN_INDEX_BACKUPS => {
352- self . index . save ( & self . index_file ) ?;
353352 self . last_index_backup = Some ( Instant :: now ( ) ) ;
353+ self . index . save ( & self . index_file ) ?;
354354 }
355355 Some ( _) => { }
356356 None => self . last_index_backup = Some ( Instant :: now ( ) ) ,
Original file line number Diff line number Diff line change @@ -5,8 +5,8 @@ use aws_sdk_s3::config::Region;
55use aws_sdk_s3:: error:: SdkError ;
66use aws_sdk_s3:: operation:: get_object:: GetObjectError ;
77use aws_sdk_s3:: Client as S3Client ;
8+ use hyper:: body:: Buf ;
89use std:: fs:: File ;
9- use std:: io:: Cursor ;
1010use std:: path:: PathBuf ;
1111use std:: str:: FromStr ;
1212use std:: sync:: Arc ;
@@ -143,13 +143,9 @@ impl S3Storage {
143143 . await ;
144144
145145 match result {
146- Ok ( response) => {
147- // FIXME: this buffers the downloaded data into memory before deserializing it,
148- // as I'm not aware of a way to convert from AsyncRead to Read.
149- let mut buf = Vec :: new ( ) ;
150- tokio:: io:: copy ( & mut response. body . into_async_read ( ) , & mut buf) . await ?;
151- Ok ( Some ( Index :: deserialize ( & mut Cursor :: new ( buf) ) ?) )
152- }
146+ Ok ( response) => Ok ( Some ( Index :: deserialize (
147+ & mut response. body . collect ( ) . await ?. reader ( ) ,
148+ ) ?) ) ,
153149 Err ( err) => {
154150 if let SdkError :: ServiceError ( service_err) = & err {
155151 if let GetObjectError :: NoSuchKey ( _) = service_err. err ( ) {
@@ -167,7 +163,7 @@ impl S3Storage {
167163 // FIXME: this buffers the serialized data into memory before sending it, as I'm not
168164 // aware of a way to convert from Write to AsyncWrite.
169165 let mut buf = Vec :: new ( ) ;
170- index. serialize ( & mut Cursor :: new ( & mut buf) ) ?;
166+ index. serialize ( & mut buf) ?;
171167
172168 self . client
173169 . put_object ( )
You can’t perform that action at this time.
0 commit comments