Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

READY: (willbe): Provided new functionality to retry publication attempts #1334

Merged
merged 1 commit into from
May 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions module/move/willbe/src/entity/package.rs
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,7 @@ mod private
{
path : crate_dir.as_ref().into(),
temp_path : self.base_temp_dir.clone(),
retry_count : 2,
dry : self.dry,
};

Expand Down
31 changes: 26 additions & 5 deletions module/move/willbe/src/tool/cargo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ mod private

use std::path::PathBuf;
use error_tools::err;
use error_tools::for_app::format_err;
use former::Former;
use process_tools::process::*;
use wtools::error::Result;
Expand Down Expand Up @@ -92,6 +93,8 @@ mod private
{
pub( crate ) path : PathBuf,
pub( crate ) temp_path : Option< PathBuf >,
#[ former( default = 0usize ) ]
pub( crate ) retry_count : usize,
pub( crate ) dry : bool,
}

Expand Down Expand Up @@ -140,11 +143,29 @@ mod private
}
else
{
Run::former()
.bin_path( program )
.args( arguments.into_iter().map( OsString::from ).collect::< Vec< _ > >() )
.current_path( args.path )
.run().map_err( | report | err!( report.to_string() ) )
let mut results = Vec::with_capacity( args.retry_count + 1 );
let run_args = arguments.into_iter().map( OsString::from ).collect::< Vec< _ > >();
for _ in 0 .. args.retry_count + 1
{
let result = Run::former()
.bin_path( program )
.args( run_args.clone() )
.current_path( &args.path )
.run();
match result
{
Ok( report ) => return Ok( report ),
Err( e ) => results.push( e ),
}
}
if args.retry_count > 0
{
Err( format_err!( "It took {} attempts, but still failed. Here are the errors:\n{}", args.retry_count + 1, results.into_iter().map( | r | format!( "- {r}" ) ).collect::< Vec< _ > >().join( "\n" ) ) )
}
else
{
Err( results.remove( 0 ) ).map_err( | report | err!( report.to_string() ) )
}
}
}
}
Expand Down
Loading