Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/C/Firefox/tools/update-verify/marannon/src/   (Firefox Browser Version 153.0.1©)  Datei vom 27.6.2026 mit Größe 1 kB image not shown  

Quelle  downloader.rs   Sprache: Rust

 

/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at https://mozilla.org/MPL/2.0/. */


use std::fs::{exists, File};
use std::io::copy;
use std::os::unix::fs::symlink;
use std::path::Path;

use anyhow::Result;
use log::info;
use ureq;

/// A simple trait to facilitate unit testing of functions that download files.
pub(crate) trait FileDownloader {
    fn fetch(&self, url: &str, dest: &Path, cache_dir: &Path) -> Result<()>;
}

pub(crate) struct UreqDownloader;

impl FileDownloader for UreqDownloader {
    fn fetch(&self, url: &str, dest: &Path, cache_dir: &Path) -> Result<()> {
        let mut cached_path = cache_dir.to_path_buf();
        cached_path.push(url_to_filename(url));

        if exists(&cached_path)? {
            info!(
                "{} already exists, not downloading {}",
                cached_path.display(),
                url
            );
        } else {
            info!("Downloading {} to {}", url, cached_path.display());
            let mut response = ureq::get(url).call()?.into_body().into_reader();
            let mut dest_file = File::create(&cached_path)?;
            copy(&mut response, &mut dest_file)?;
        }

        // The file we want is now at `cached_path`; now we can symlink it to
        // the desired location.
        symlink(cached_path, dest)?;

        return Ok(());
    }
}

fn url_to_filename(url: &str) -> String {
    return url.replace(":", "_").replace("/", "_");
}

Messung V0.5 in Prozent
C=92 H=100 G=95

¤ Dauer der Verarbeitung: 0.10 Sekunden  (vorverarbeitet am  2026-09-30) ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

PVS Prover

Isabelle Prover

NIST Cobol Testsuite

Cephes Mathematical Library

Vienna Development Method

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.