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 {
349
349
// time elapsed since the last save.
350
350
match self . last_index_backup {
351
351
Some ( last) if last. elapsed ( ) >= MINIMUM_DELAY_BETWEEN_INDEX_BACKUPS => {
352
- self . index . save ( & self . index_file ) ?;
353
352
self . last_index_backup = Some ( Instant :: now ( ) ) ;
353
+ self . index . save ( & self . index_file ) ?;
354
354
}
355
355
Some ( _) => { }
356
356
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;
5
5
use aws_sdk_s3:: error:: SdkError ;
6
6
use aws_sdk_s3:: operation:: get_object:: GetObjectError ;
7
7
use aws_sdk_s3:: Client as S3Client ;
8
+ use hyper:: body:: Buf ;
8
9
use std:: fs:: File ;
9
- use std:: io:: Cursor ;
10
10
use std:: path:: PathBuf ;
11
11
use std:: str:: FromStr ;
12
12
use std:: sync:: Arc ;
@@ -143,13 +143,9 @@ impl S3Storage {
143
143
. await ;
144
144
145
145
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
+ ) ?) ) ,
153
149
Err ( err) => {
154
150
if let SdkError :: ServiceError ( service_err) = & err {
155
151
if let GetObjectError :: NoSuchKey ( _) = service_err. err ( ) {
@@ -167,7 +163,7 @@ impl S3Storage {
167
163
// FIXME: this buffers the serialized data into memory before sending it, as I'm not
168
164
// aware of a way to convert from Write to AsyncWrite.
169
165
let mut buf = Vec :: new ( ) ;
170
- index. serialize ( & mut Cursor :: new ( & mut buf) ) ?;
166
+ index. serialize ( & mut buf) ?;
171
167
172
168
self . client
173
169
. put_object ( )
You can’t perform that action at this time.
0 commit comments