@@ -588,7 +588,7 @@ pub(crate) fn source_archive_path(name: &str, version: &str) -> String {
588
588
}
589
589
590
590
#[ instrument( skip( storage) ) ]
591
- fn migrate_one ( storage : & Storage , archive_path : & str ) -> Result < ( ) > {
591
+ fn migrate_one ( storage : & Storage , archive_path : & str , tmpdir : & Path ) -> Result < ( ) > {
592
592
// this will also download the index if it doesn't exist locally
593
593
let local_index_filename = storage. get_index_filename ( archive_path) ?;
594
594
@@ -599,7 +599,8 @@ fn migrate_one(storage: &Storage, archive_path: &str) -> Result<()> {
599
599
600
600
info ! ( "converting local index..." ) ;
601
601
let remote_index_path = format ! ( "{}.index" , & archive_path) ;
602
- let new_index_temp_path = archive_index:: convert_to_sqlite_index ( & local_index_filename) ?;
602
+ let new_index_temp_path =
603
+ archive_index:: convert_to_sqlite_index ( & local_index_filename, tmpdir) ?;
603
604
604
605
// first upload to S3, ongoing requests will still use the local CBOR index
605
606
info ! ( "uplading to S3..." ) ;
@@ -621,6 +622,11 @@ pub fn migrate_old_archive_indexes(
621
622
storage : & Storage ,
622
623
conn : & mut impl postgres:: GenericClient ,
623
624
) -> Result < ( ) > {
625
+ let tmpdir = storage. config . prefix . join ( "archive_cache_tmp" ) ;
626
+ if !tmpdir. exists ( ) {
627
+ fs:: create_dir ( & tmpdir) ?;
628
+ }
629
+
624
630
for row in conn
625
631
. query_raw (
626
632
"
@@ -643,10 +649,10 @@ pub fn migrate_old_archive_indexes(
643
649
let version: & str = row. get ( 1 ) ;
644
650
info ! ( "converting archive index for {} {}..." , name, version) ;
645
651
646
- if let Err ( err) = migrate_one ( storage, & rustdoc_archive_path ( name, version) ) {
652
+ if let Err ( err) = migrate_one ( storage, & rustdoc_archive_path ( name, version) , & tmpdir ) {
647
653
error ! ( "error converting rustdoc archive index: {:?}" , err) ;
648
654
}
649
- if let Err ( err) = migrate_one ( storage, & source_archive_path ( name, version) ) {
655
+ if let Err ( err) = migrate_one ( storage, & source_archive_path ( name, version) , & tmpdir ) {
650
656
error ! ( "error converting source archive index: {:?}" , err) ;
651
657
}
652
658
}
0 commit comments