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

question about plugin #5

Open
LollipopFt opened this issue Jul 28, 2022 · 1 comment
Open

question about plugin #5

LollipopFt opened this issue Jul 28, 2022 · 1 comment

Comments

@LollipopFt
Copy link

LollipopFt commented Jul 28, 2022

is this line meant to be "download.lock" instead?

let lock_file = PathBuf::from("donwload.lock");

also, is it possible to use octocrab (or something preferably much more lightweight?) to auto download the latest version?
"https://github.com/rust-analyzer/rust-analyzer/releases/download/2022-07-18/{}.gz",

e.g.

use octocrab::models::repos::Release;

async fn main() {
    let ranalyzer = octocrab
        .repos("rust-lang", "rust-analyzer")
        .releases()
        .list()
        .per_page(5)
        .page(1u32)
        .send()
        .await
        .expect("failed to get rust-analyzer");
    for release in ranalyzer {
        if let Some(name) = &release.name {
            if !name.contains("nightly") {
                get_asset(release, "{asset name here}", aspath).await;
                break;
            }
        }
    }
}

async fn get_asset(release: Release, name: &str, path: &Path) {
    for asset in release.assets {
        if asset.name.contains(name) {
            let url_load: String = asset.browser_download_url.into();
            let response = reqwest::get(url_load).await.expect("");
            let mut file = File::create(path).expect("could not create file.");
            let content = response.bytes().await.expect("failed response");
            file.write_all(content.as_ref())
                .expect("could not write content.");
        }
    }
}
@MinusGix
Copy link
Member

is this line meant to be "download.lock" instead?

It is a spelling mistake we haven't bothered to fix :p

also, is it possible to use octocrab (or something preferably much more lightweight?) to auto download the latest version?

It would probably be easier just to make a script that updates this repo with the newest version whenever it comes out, and then Lapce users can just upgrade the plugin that way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants