11#![ deny( clippy:: dbg_macro) ]
22#![ deny( clippy:: disallowed_methods) ]
33
4- use anyhow:: { Context , Result , bail , ensure} ;
4+ use anyhow:: { Context , Result , ensure} ;
55use camino:: { Utf8Path , Utf8PathBuf } ;
66use clap:: Parser ;
7- use create_output_dir:: create_output_dir;
7+ use create_output_dir:: { create_output_dir, incremental_create_execution_output_dir } ;
88use indoc:: { formatdoc, indoc} ;
99use mimalloc:: MiMalloc ;
1010use scarb_extensions_cli:: execute:: ToArgs ;
@@ -13,9 +13,9 @@ use scarb_metadata::{Metadata, MetadataCommand, ScarbCommand};
1313use scarb_ui:: args:: { PackagesFilter , ToEnvVars } ;
1414use scarb_ui:: components:: Status ;
1515use scarb_ui:: { OutputFormat , Ui } ;
16+ use std:: env;
1617use std:: fs;
1718use std:: process:: ExitCode ;
18- use std:: { env, io} ;
1919use stwo_cairo_adapter:: vm_import:: adapt_vm_output;
2020use stwo_cairo_prover:: cairo_air:: prover:: {
2121 ProverConfig , ProverParameters , default_prod_prover_parameters, prove_cairo,
@@ -25,8 +25,6 @@ use stwo_cairo_prover::stwo_prover::core::vcs::blake2_merkle::Blake2sMerkleChann
2525#[ global_allocator]
2626static GLOBAL : MiMalloc = MiMalloc ;
2727
28- const MAX_ITERATION_COUNT : usize = 10000 ;
29-
3028fn main ( ) -> ExitCode {
3129 let args = Args :: parse ( ) ;
3230 let ui = Ui :: new ( args. verbose . clone ( ) . into ( ) , OutputFormat :: Text ) ;
@@ -65,7 +63,8 @@ fn main_inner(args: Args, ui: Ui) -> Result<()> {
6563 let scarb_target_dir = Utf8PathBuf :: from ( env:: var ( "SCARB_TARGET_DIR" ) ?) ;
6664 let output_dir = scarb_target_dir. join ( "execute" ) . join ( & package. name ) ;
6765 create_output_dir ( output_dir. as_std_path ( ) ) ?;
68- let ( _execution_output_dir, execution_id) = incremental_create_output_dir ( & output_dir) ?;
66+ let ( _execution_output_dir, execution_id) =
67+ incremental_create_execution_output_dir ( & output_dir) ?;
6968
7069 let filter = PackagesFilter :: generate_for :: < Metadata > ( vec ! [ package. clone( ) ] . iter ( ) ) ;
7170 ScarbCommand :: new ( )
@@ -163,20 +162,3 @@ fn display_path(scarb_target_dir: &Utf8Path, output_path: &Utf8Path) -> String {
163162 Err ( _) => output_path. to_string ( ) ,
164163 }
165164}
166-
167- fn incremental_create_output_dir ( path : & Utf8Path ) -> Result < ( Utf8PathBuf , usize ) > {
168- for i in 1 ..=MAX_ITERATION_COUNT {
169- let filepath = path. join ( format ! ( "execution{i}" ) ) ;
170- let result = fs:: create_dir ( & filepath) ;
171- return match result {
172- Err ( e) => {
173- if e. kind ( ) == io:: ErrorKind :: AlreadyExists {
174- continue ;
175- }
176- Err ( e. into ( ) )
177- }
178- Ok ( _) => Ok ( ( filepath, i) ) ,
179- } ;
180- }
181- bail ! ( "failed to create output directory" )
182- }
0 commit comments