@@ -588,7 +588,7 @@ pub(crate) fn source_archive_path(name: &str, version: &str) -> String {
588588}
589589
590590#[ 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 < ( ) > {
592592 // this will also download the index if it doesn't exist locally
593593 let local_index_filename = storage. get_index_filename ( archive_path) ?;
594594
@@ -599,7 +599,8 @@ fn migrate_one(storage: &Storage, archive_path: &str) -> Result<()> {
599599
600600 info ! ( "converting local index..." ) ;
601601 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) ?;
603604
604605 // first upload to S3, ongoing requests will still use the local CBOR index
605606 info ! ( "uplading to S3..." ) ;
@@ -621,6 +622,11 @@ pub fn migrate_old_archive_indexes(
621622 storage : & Storage ,
622623 conn : & mut impl postgres:: GenericClient ,
623624) -> Result < ( ) > {
625+ let tmpdir = storage. config . prefix . join ( "archive_cache_tmp" ) ;
626+ if !tmpdir. exists ( ) {
627+ fs:: create_dir ( & tmpdir) ?;
628+ }
629+
624630 for row in conn
625631 . query_raw (
626632 "
@@ -643,10 +649,10 @@ pub fn migrate_old_archive_indexes(
643649 let version: & str = row. get ( 1 ) ;
644650 info ! ( "converting archive index for {} {}..." , name, version) ;
645651
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 ) {
647653 error ! ( "error converting rustdoc archive index: {:?}" , err) ;
648654 }
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 ) {
650656 error ! ( "error converting source archive index: {:?}" , err) ;
651657 }
652658 }
0 commit comments