11#![ expect( clippy:: unwrap_used, reason = "contains legacy code which uses unwrap" ) ]
22
3- use crate :: api:: Api ;
43use crate :: config:: Config ;
5- use crate :: constants:: DEFAULT_MAX_WAIT ;
64use crate :: utils:: args:: ArgExt as _;
75use crate :: utils:: file_search:: ReleaseFileSearch ;
8- use crate :: utils:: file_upload:: { FileUpload , SourceFile , UploadContext } ;
6+ use crate :: utils:: file_upload:: SourceFile ;
97use crate :: utils:: fs:: path_as_url;
8+ use crate :: utils:: source_bundle:: { self , BundleContext } ;
109use anyhow:: { bail, Context as _, Result } ;
1110use clap:: { Arg , ArgMatches , Command } ;
1211use sentry:: types:: DebugId ;
@@ -54,19 +53,8 @@ pub fn execute(matches: &ArgMatches) -> Result<()> {
5453 let config = Config :: current ( ) ;
5554 let org = config. get_org ( matches) ?;
5655 let project = config. get_project ( matches) . ok ( ) ;
57- let api = Api :: current ( ) ;
58- let chunk_upload_options = api. authenticated ( ) ?. get_chunk_upload_options ( & org) ?;
5956
60- let context = & UploadContext {
61- org : & org,
62- projects : project. as_slice ( ) . try_into ( ) . ok ( ) ,
63- release : None ,
64- dist : None ,
65- note : None ,
66- wait : true ,
67- max_wait : DEFAULT_MAX_WAIT ,
68- chunk_upload_options : chunk_upload_options. as_ref ( ) ,
69- } ;
57+ let context = BundleContext :: new ( & org) . with_projects ( project. as_slice ( ) ) ;
7058 let path = matches. get_one :: < PathBuf > ( "path" ) . unwrap ( ) ;
7159 let output_path = matches. get_one :: < PathBuf > ( "output" ) . unwrap ( ) ;
7260 let debug_id = matches. get_one :: < DebugId > ( "debug_id" ) . unwrap ( ) ;
@@ -88,30 +76,23 @@ pub fn execute(matches: &ArgMatches) -> Result<()> {
8876 }
8977
9078 let sources = ReleaseFileSearch :: new ( path. to_path_buf ( ) ) . collect_files ( ) ?;
91- let files = sources
92- . iter ( )
93- . map ( |source| {
94- let local_path = source. path . strip_prefix ( & source. base_path ) . unwrap ( ) ;
95- let local_path_jvm_ext = local_path. with_extension ( "jvm" ) ;
96- let url = format ! ( "~/{}" , path_as_url( & local_path_jvm_ext) ) ;
97- (
98- url. clone ( ) ,
99- SourceFile {
100- url,
101- path : source. path . clone ( ) ,
102- contents : Arc :: new ( source. contents . clone ( ) ) ,
103- ty : SourceFileType :: Source ,
104- headers : BTreeMap :: new ( ) ,
105- messages : vec ! [ ] ,
106- already_uploaded : false ,
107- } ,
108- )
109- } )
110- . collect ( ) ;
79+ let files = sources. iter ( ) . map ( |source| {
80+ let local_path = source. path . strip_prefix ( & source. base_path ) . unwrap ( ) ;
81+ let local_path_jvm_ext = local_path. with_extension ( "jvm" ) ;
82+ let url = format ! ( "~/{}" , path_as_url( & local_path_jvm_ext) ) ;
11183
112- let tempfile = FileUpload :: new ( context)
113- . files ( & files)
114- . build_jvm_bundle ( Some ( * debug_id) )
84+ SourceFile {
85+ url,
86+ path : source. path . clone ( ) ,
87+ contents : Arc :: new ( source. contents . clone ( ) ) ,
88+ ty : SourceFileType :: Source ,
89+ headers : BTreeMap :: new ( ) ,
90+ messages : vec ! [ ] ,
91+ already_uploaded : false ,
92+ }
93+ } ) ;
94+
95+ let tempfile = source_bundle:: build ( context, files, Some ( * debug_id) )
11596 . context ( "Unable to create source bundle" ) ?;
11697
11798 fs:: copy ( tempfile. path ( ) , & out) . context ( "Unable to write source bundle" ) ?;
0 commit comments