This repository was archived by the owner on Oct 18, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +7
-7
lines changed Expand file tree Collapse file tree 3 files changed +7
-7
lines changed Original file line number Diff line number Diff line change @@ -25,6 +25,7 @@ arc-swap = "1.6"
25
25
chrono = " 0.4.23"
26
26
uuid = " 1.4.1"
27
27
rand = " 0.8.5"
28
+ tempfile = " 3.3.0"
28
29
29
30
[features ]
30
31
libsql_linked_statically = []
Original file line number Diff line number Diff line change @@ -158,18 +158,18 @@ pub async fn upload_s3_multipart(
158
158
//
159
159
// This would only happen to databases that are around ~1 TiB.
160
160
if !has_reached_eof {
161
- let mut last_chunk_path = std:: env:: temp_dir ( ) ;
162
- last_chunk_path. push ( rand:: random :: < u32 > ( ) . to_string ( ) ) ;
161
+ let last_chunk_file = tempfile:: NamedTempFile :: new ( ) ?;
162
+ let mut last_chunk_tokio_file =
163
+ tokio:: fs:: File :: from_std ( last_chunk_file. as_file ( ) . try_clone ( ) ?) ;
163
164
164
- let mut last_chunk_file = tokio:: fs:: File :: create ( & last_chunk_path) . await ?;
165
- tokio:: io:: copy ( & mut reader, & mut last_chunk_file) . await ?;
165
+ tokio:: io:: copy ( & mut reader, & mut last_chunk_tokio_file) . await ?;
166
166
167
167
let part_out = client
168
168
. upload_part ( )
169
169
. bucket ( bucket)
170
170
. key ( key)
171
171
. upload_id ( upload_id. clone ( ) )
172
- . body ( ByteStream :: from_path ( & last_chunk_path ) . await ?)
172
+ . body ( ByteStream :: from_path ( last_chunk_file . path ( ) ) . await ?)
173
173
. part_number ( LAST_PART )
174
174
. send ( )
175
175
. await ?;
@@ -184,8 +184,6 @@ pub async fn upload_s3_multipart(
184
184
)
185
185
. build ( ) ,
186
186
) ;
187
-
188
- let _ = tokio:: fs:: remove_file ( last_chunk_path) . await ;
189
187
}
190
188
191
189
client
You can’t perform that action at this time.
0 commit comments