File tree Expand file tree Collapse file tree 1 file changed +8
-7
lines changed Expand file tree Collapse file tree 1 file changed +8
-7
lines changed Original file line number Diff line number Diff line change 1
1
use std:: {
2
2
collections:: { HashMap , HashSet } ,
3
+ fs:: File ,
3
4
io:: Write ,
4
5
path:: { Path , PathBuf } ,
5
6
str,
@@ -192,15 +193,15 @@ fn write_chunk(
192
193
name : SavedChunkName ,
193
194
) -> Result < ( ) , Error > {
194
195
// Write to a temp file and then rename to avoid partial writes
195
- let mut temp_save =
196
- tempfile:: NamedTempFile :: new ( ) . map_err ( |e| Error ( ErrorKind :: CreateTempFile ( e) ) ) ?;
197
- let temp_save_path = temp_save. path ( ) . to_owned ( ) ;
198
- temp_save
199
- . as_file_mut ( )
196
+ let temp_dir =
197
+ tempfile:: TempDir :: new_in ( root) . map_err ( |e| Error ( ErrorKind :: CreateTempFile ( e) ) ) ?;
198
+ let temp_save_path = temp_dir. path ( ) . join ( name. filename ( ) ) ;
199
+ let mut temp_save_file =
200
+ File :: create ( & temp_save_path) . map_err ( |e| Error ( ErrorKind :: CreateTempFile ( e) ) ) ?;
201
+ temp_save_file
200
202
. write_all ( chunk)
201
203
. map_err ( |e| Error ( ErrorKind :: WriteTempFile ( temp_save_path. clone ( ) , e) ) ) ?;
202
- temp_save
203
- . as_file_mut ( )
204
+ temp_save_file
204
205
. sync_all ( )
205
206
. map_err ( |e| Error ( ErrorKind :: WriteTempFile ( temp_save_path. clone ( ) , e) ) ) ?;
206
207
You can’t perform that action at this time.
0 commit comments