An open API service indexing awesome lists of open source software.

https://github.com/bdr-pro/auto_downloader

👋 Welcome to auto_downloader, the coolest Rust project for automatically updating your app with zero hassle.
https://github.com/bdr-pro/auto_downloader

automation crates downloader rust

Last synced: about 1 year ago
JSON representation

👋 Welcome to auto_downloader, the coolest Rust project for automatically updating your app with zero hassle.

Awesome Lists containing this project

README

          

# 🚀 Auto Downloader 🚀

Hey there, fellow Rustacean! 👋 Welcome to `auto_downloader`, the coolest Rust project for automatically updating your app with zero hassle. Whether you're looking to keep your application up-to-date without lifting a finger or just dabbling in Rust, you've come to the right place!

## What's This Project All About? 🤔

In the digital world, staying updated is the name of the game. That's why `auto_downloader` is here to save the day! It checks for updates, downloads the new version, and gets your app running the latest and greatest version in no time. It's like having a little robot 🤖 inside your computer, making sure you're always at the cutting edge.

## Getting Started 🚀

### Prerequisites

- Rust installed on your machine (duh! 😜). If you don't have it yet, visit [the official Rust website](https://www.rust-lang.org/tools/install) to get set up!

### Installation

add this to your `Cargo.toml` file:

```toml
[dependencies]
auto_downloader = "0.2.0"
```

Voilà! You're now running `auto_downloader`. Watch it work its magic! ✨

## Features 🌟

- **Automatic Updates**: Checks for updates and downloads them without you having to move a muscle.
- **Secure**: Verifies download integrity to keep the nasties away. 🛡️
- **Cross-Platform Goodness**: Works on all your favorite platforms. 🖥️ 🍏 🪟

## How to Use 🛠️

Honestly? Just let it do its thing! `auto_downloader` works in the background, ensuring your application is always up to date. For those who like to tinker, dive into the `src` folder to see how the magic happens. Who knows, you might find some cool ideas for your next Rust project!

## Contributing 🤝

Want to contribute? Awesome! Feel free to fork the repo, make your changes, and submit a pull request. All ideas and contributions are welcome. Let's make `auto_downloader` even better together!

## License 📜

This project is proudly licensed under the MIT License. See the [LICENSE](LICENSE.md) file for details.

## Final Words 📢

Thanks for checking out `auto_downloader`! If you like what you see, give it a star ⭐, and share it with your friends. Happy coding, and may your applications always be up-to-date!

## Example

```json
{
"version": "1.0.1",
"download_url": "https://example.com/your_application_1.0.1.exe",
"sha256_checksum": "d73d56b328d5a8ffdf27430edb4d9d68e1e2a8f2c3e2656c672e4f6b76153a2b",
"app_name": "your_application.exe"
}
```

## Code

- **in updater.rs**

```rust
use auto_downloader;
use std::{env, fs, process::Command, thread::sleep, time::Duration};

fn main() {
let info_url = "https://example.com/version_info.json";

let Ok(version_info) = common::get_version_info(info_url) else {
eprintln!("Failed to get update info.");
return;
};

let temp_path = env::temp_dir().join("update_new.bin");
println!("⬇️ Downloading new version...");
if let Err(e) = common::download_new_version(&version_info.download_url, &temp_path) {
eprintln!("Download failed: {}", e);
return;
}

println!("🔒 Verifying checksum...");
match common::compute_file_sha256(&temp_path) {
Ok(hash) if hash != version_info.sha256_checksum => {
eprintln!("❌ Checksum mismatch. Aborting update.");
return;
}
Ok(_) => println!("✅ Checksum verified."),
Err(e) => {
eprintln!("Error computing checksum: {}", e);
return;
}
}

let app_path = env::current_dir().unwrap().join(&version_info.app_name);

// Wait for the main app to exit
println!("⏳ Waiting for app to close...");
sleep(Duration::from_secs(1));

if cfg!(target_os = "windows") {
fs::remove_file(&app_path).ok();
}

println!("🔄 Replacing binary...");
fs::rename(&temp_path, &app_path).expect("Failed to replace binary");

println!("🚀 Launching new version...");
Command::new(&app_path)
.spawn()
.expect("Failed to launch new version");
}

```

- **in main.rs**

```rust

use auto_downloader::get_version_info;
use std::process::Command;

fn main() {
let current_version = "1.0.0";
let info_url = "https://example.com/version_info.json";

match get_version_info(info_url) {
Ok(info) if info.version != current_version => {
println!("Update available. Launching updater...");
Command::new("updater")
.spawn()
.expect("Failed to launch updater");
std::process::exit(0);
}
Ok(_) => println!("✅ You're up to date!"),
Err(e) => eprintln!("Failed to check version: {}", e),
}

// Your real app logic goes here
println!("🧠 Main app is running...");
}

/*

{
"version": "1.0.1",
"download_url": "https://example.com/your_application_1.0.1.exe",
"sha256_checksum": "d73d56b328d5a8ffdf27430edb4d9d68e1e2a8f2c3e2656c672e4f6b76153a2b",
"app_name": "your_application.exe"
}

*/

```

## Authors

👤 **Bader alotaibi** @ **

## Show your support

Give a ⭐️ if you like this project!