pub fn update_from_dist<'a>(
    download: DownloadCfg<'a>,
    update_hash: Option<&Path>,
    toolchain: &ToolchainDesc,
    profile: Option<Profile>,
    prefix: &InstallPrefix,
    force_update: bool,
    old_date: Option<&str>,
    components: &[&str],
    targets: &[&str],
) -> Result<Option<String>> {
    let fresh_install = !prefix.path().exists();
    let hash_exists = update_hash.map(Path::exists).unwrap_or(false);

    // fresh_install means the toolchain isn't present, but hash_exists means there is a stray hash file
    if fresh_install && hash_exists {
        // It's ok to unwrap, because hash have to exist at this point
        (download.notify_handler)(Notification::StrayHash(update_hash.unwrap()));
        std::fs::remove_file(update_hash.unwrap())?;
    }

    let res = update_from_dist_(
        download,
        update_hash,
        toolchain,
        profile,
        prefix,
        force_update,
        old_date,
        components,
        targets,
    );

    // Don't leave behind an empty / broken installation directory
    if res.is_err() && fresh_install {
        // FIXME Ignoring cascading errors
        let _ = utils::remove_dir("toolchain", prefix.path(), download.notify_handler);
    }

    res
}
// Installs or updates a toolchain from a dist server. If an initial
// install then it will be installed with the default components. If
// an upgrade then all the existing components will be upgraded.
//
// Returns the manifest's hash if anything changed.
Installs or updates a toolchain from a dist server. If an initial
install then it will be installed with the default components. If
an upgrade then all the existing components will be upgraded.

Returns the manifest's hash if anything changed.
Installs or updates a toolchain from a dist server . If an initial install then it will be installed with the default components . If an upgrade then all the existing components will be upgraded . Returns the manifest ' s hash if anything changed .
pub fn update_from_dist<'a>(
    download: DownloadCfg<'a>,
    update_hash: Option<&Path>,
    toolchain: &ToolchainDesc,
    profile: Option<Profile>,
    prefix: &InstallPrefix,
    force_update: bool,
    old_date: Option<&str>,
    components: &[&str],
    targets: &[&str],
) -> Result<Option<String>> {
    let fresh_install = !prefix.path().exists();
    let hash_exists = update_hash.map(Path::exists).unwrap_or(false);
    // fresh_install means the toolchain isn't present, but hash_exists means there is a stray hash file
    if fresh_install && hash_exists {
        // It's ok to unwrap, because hash have to exist at this point
        (download.notify_handler)(Notification::StrayHash(update_hash.unwrap()));
        std::fs::remove_file(update_hash.unwrap())?;
    }
    let res = update_from_dist_(
        download,
        update_hash,
        toolchain,
        profile,
        prefix,
        force_update,
        old_date,
        components,
        targets,
    );
    // Don't leave behind an empty / broken installation directory
    if res.is_err() && fresh_install {
        // FIXME Ignoring cascading errors
        let _ = utils::remove_dir("toolchain", prefix.path(), download.notify_handler);
    }
    res
}
pub fn update_from_dist < ' a > ( download : DownloadCfg < ' a > , update_hash : Option < & Path > , toolchain : & ToolchainDesc , profile : Option < Profile > , prefix : & InstallPrefix , force_update : bool , old_date : Option < & str > , components : & [ & str ] , targets : & [ & str ] , ) -> Result < Option < String > > { let fresh_install = ! prefix . path ( ) . exists ( ) ; let hash_exists = update_hash . map ( Path :: exists ) . unwrap_or ( false ) ; // fresh_install means the toolchain isn't present, but hash_exists means there is a stray hash file if fresh_install && hash_exists { // It's ok to unwrap, because hash have to exist at this point ( download . notify_handler ) ( Notification :: StrayHash ( update_hash . unwrap ( ) ) ) ; std :: fs :: remove_file ( update_hash . unwrap ( ) ) ? ; } let res = update_from_dist_ ( download , update_hash , toolchain , profile , prefix , force_update , old_date , components , targets , ) ; // Don't leave behind an empty / broken installation directory if res . is_err ( ) && fresh_install { // FIXME Ignoring cascading errors let _ = utils :: remove_dir ( " " , prefix . path ( ) , download . notify_handler ) ; } res }
Installs or updates a toolchain from a dist server.
Installs or updates a toolchain from a dist server .
download
DownloadCfg<'a>
update_hash
Option<&Path>
toolchain
&ToolchainDesc
profile
Option<Profile>
prefix
&InstallPrefix
force_update
bool
old_date
Option<&str>
components
&[&str]
targets
&[&str]