/// Uploads a package to the depot. All packages are always
/// automatically put into the `unstable` channel, but if
/// `additional_release_channel` is provided, packages will be
/// promoted to that channel as well.
Uploads a package to the depot. All packages are always
automatically put into the `unstable` channel, but if
`additional_release_channel` is provided, packages will be
promoted to that channel as well.
Uploads a package to the depot . All packages are always automatically put into the ` unstable ` channel but if ` additional_release_channel ` is provided packages will be promoted to that channel as well .
fn upload_into_depot(ui: &mut UI,
                     api_client: &BoxedClient,
                     token: &str,
                     (ident, target): (&PackageIdent, PackageTarget),
                     additional_release_channel: &Option<ChannelIdent>,
                     force_upload: bool,
                     mut archive: &mut PackageArchive)
                     -> Result<()> {
    ui.status(Status::Uploading, archive.path.display())?;
    let package_uploaded =
        match api_client.put_package(&mut archive, token, force_upload, ui.progress()) {
            Ok(_) => true,
            Err(api_client::Error::APIError(StatusCode::Conflict, _)) => {
                println!("Package already exists on remote; skipping.");
                true
            }
            Err(api_client::Error::APIError(StatusCode::UnprocessableEntity, _)) => {
                return Err(Error::PackageArchiveMalformed(format!("{}",
                                                                  archive.path
                                                                         .display())));
            }
            Err(api_client::Error::APIError(StatusCode::NotImplemented, _)) => {
                println!("Package platform or architecture not supported by the targeted depot; \
                          skipping.");
                false
            }
            Err(api_client::Error::APIError(StatusCode::FailedDependency, _)) => {
                ui.fatal("Package upload introduces a circular dependency - please check \
                          pkg_deps; skipping.")?;
                false
            }
            Err(e) => return Err(Error::from(e)),
        };
    ui.status(Status::Uploaded, ident)?;
    // Promote to additional_release_channel if specified
    if package_uploaded && additional_release_channel.is_some() {
        let channel = additional_release_channel.clone().unwrap();
        ui.begin(format!("Promoting {} to channel '{}'", ident, channel))?;
        if channel != ChannelIdent::stable() && channel != ChannelIdent::unstable() {
            match api_client.create_channel(&ident.origin, &channel, token) {
                Ok(_) => (),
                Err(api_client::Error::APIError(StatusCode::Conflict, _)) => (),
                Err(e) => return Err(Error::from(e)),
            };
        }
        match api_client.promote_package((ident, target), &channel, token) {
            Ok(_) => (),
            Err(e) => return Err(Error::from(e)),
        };
        ui.status(Status::Promoted, ident)?;
    }
    Ok(())
}
fn upload_into_depot ( ui : & mut UI , api_client : & BoxedClient , token : & str , ( ident , target ) : ( & PackageIdent , PackageTarget ) , additional_release_channel : & Option < ChannelIdent > , force_upload : bool , mut archive : & mut PackageArchive ) -> Result < ( ) > { ui . status ( Status :: Uploading , archive . path . display ( ) ) ? ; let package_uploaded = match api_client . put_package ( & mut archive , token , force_upload , ui . progress ( ) ) { Ok ( _ ) => true , Err ( api_client :: Error :: APIError ( StatusCode :: Conflict , _ ) ) => { println ! ( " " ) ; true } Err ( api_client :: Error :: APIError ( StatusCode :: UnprocessableEntity , _ ) ) => { return Err ( Error :: PackageArchiveMalformed ( format ! ( " " archive path display ( ) ) ) ) ; } Err ( api_client :: Error :: APIError ( StatusCode :: NotImplemented , _ ) ) => { println ! ( " \
 " ) ; false } Err ( api_client :: Error :: APIError ( StatusCode :: FailedDependency , _ ) ) => { ui . fatal ( " \
 " ) ? ; false } Err ( e ) => return Err ( Error :: from ( e ) ) , } ; ui . status ( Status :: Uploaded , ident ) ? ; // Promote to additional_release_channel if specified if package_uploaded && additional_release_channel . is_some ( ) { let channel = additional_release_channel . clone ( ) . unwrap ( ) ; ui . begin ( format ! ( " " ident channel ) ) ? ; if channel != ChannelIdent :: stable ( ) && channel != ChannelIdent :: unstable ( ) { match api_client . create_channel ( & ident . origin , & channel , token ) { Ok ( _ ) => ( ) , Err ( api_client :: Error :: APIError ( StatusCode :: Conflict , _ ) ) => ( ) , Err ( e ) => return Err ( Error :: from ( e ) ) , } ; } match api_client . promote_package ( ( ident , target ) , & channel , token ) { Ok ( _ ) => ( ) , Err ( e ) => return Err ( Error :: from ( e ) ) , } ; ui . status ( Status :: Promoted , ident ) ? ; } Ok ( ( ) ) }
Uploads a package to the depot.
Uploads a package to the depot .
ui
&mut UI
api_client
&BoxedClient
token
(&PackageIdent, PackageTarget)
additional_release_channel
&Option<ChannelIdent>
force_upload
bool
archive
&mut PackageArchive