Skip to content

Commit b83ade3

Browse files
committed
chore: update dependencies and refactor authentication to use dynamic keyring configuration for improved flexibility and maintainability
chore(rclone.rs): remove rclone.rs file as it is no longer needed in the project feat(uploader): add R2Uploader for uploading files to S3-compatible storage with progress tracking
1 parent 2297c19 commit b83ade3

8 files changed

Lines changed: 814 additions & 1023 deletions

File tree

Cargo.lock

Lines changed: 525 additions & 640 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ path = "src/main.rs"
1818
[dependencies]
1919
# CLI Framework
2020
clap = { version = "4.5", features = ["derive", "env"] }
21-
clap_complete = "4.5"
2221

2322
# Async Runtime
2423
tokio = { version = "1.40", features = ["full"] }
24+
futures = "0.3"
2525

2626
# HTTP Client
2727
reqwest = { version = "0.12", features = ["json", "stream", "multipart"] }
@@ -37,31 +37,23 @@ thiserror = "1.0"
3737

3838
# Progress & UI
3939
indicatif = "0.17"
40-
colored = "2.1"
4140

4241
# Cross-platform paths
4342
directories = "5.0"
4443

45-
# Logging
46-
tracing = "0.1"
47-
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
44+
# Object storage uploads
45+
opendal = { version = "0.49", features = ["services-s3"] }
4846

4947
# File operations
50-
sha2 = "0.10"
5148
walkdir = "2.5"
5249
tempfile = "3.10"
53-
flate2 = "1.0"
54-
tar = "0.4"
55-
zip = "2.1"
5650

5751
# Authentication
5852
keyring = { version = "3.0", features = ["apple-native", "windows-native", "linux-native"] }
5953
tiny_http = "0.12"
6054
open = "5.0"
6155
url = "2.5"
6256
urlencoding = "2.1"
63-
strip-ansi-escapes = "0.2"
64-
portable-pty = "0.8"
6557

6658

6759

src/auth.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,17 @@
11
use anyhow::Result;
22
use keyring::Entry;
33
use std::net::TcpListener;
4-
use tiny_http::{Server, Response, Method, Header};
4+
use tiny_http::{Server, Response, Header};
55
use crate::config;
66

7-
const SERVICE_NAME: &str = "wvdsh";
8-
const API_KEY_ACCOUNT: &str = "api-key";
9-
107
pub struct AuthManager {
118
api_key_entry: Entry,
129
}
1310

1411
impl AuthManager {
1512
pub fn new() -> Result<Self> {
16-
let api_key_entry = Entry::new(SERVICE_NAME, API_KEY_ACCOUNT)?;
13+
let keyring = config::keyring_config()?;
14+
let api_key_entry = Entry::new(&keyring.service, &keyring.account)?;
1715
Ok(Self { api_key_entry })
1816
}
1917

src/builds.rs

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@ use serde::{Deserialize, Serialize};
33
use std::path::PathBuf;
44
use crate::auth::AuthManager;
55
use crate::config::{self, WavedashConfig};
6-
use crate::rclone::{RcloneManager, R2Config};
6+
#[path = "uploader.rs"]
7+
mod uploader;
8+
9+
use uploader::{R2Config, R2Uploader};
710

811
#[derive(Debug, Deserialize)]
912
struct ApiErrorResponse {
@@ -172,7 +175,7 @@ pub async fn handle_build_push(
172175
&api_key
173176
).await?;
174177

175-
// Create R2 config for rclone
178+
// Create R2 config for uploader
176179
let r2_config = R2Config {
177180
access_key_id: creds.credentials.access_key_id,
178181
secret_access_key: creds.credentials.secret_access_key,
@@ -191,15 +194,11 @@ pub async fn handle_build_push(
191194
false
192195
};
193196

194-
// Initialize rclone and upload
195-
let mut rclone = RcloneManager::new(verbose)?;
196-
197-
// Upload the build directory (including wavedash.toml)
198-
rclone.sync_to_r2(
199-
upload_dir.to_str().unwrap(),
200-
&creds.bucket_name,
197+
// Initialize uploader and upload
198+
let uploader = R2Uploader::new(&r2_config, &creds.bucket_name)?;
199+
uploader.upload_directory(
200+
upload_dir.as_path(),
201201
&creds.r2_key_prefix,
202-
&r2_config,
203202
verbose,
204203
).await?;
205204

src/config.rs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ use std::path::PathBuf;
66
struct Config {
77
open_browser_website_host: String,
88
api_host: String,
9+
#[serde(default)]
10+
keyring_service: Option<String>,
11+
#[serde(default)]
12+
keyring_account: Option<String>,
913
}
1014

1115
impl Config {
@@ -19,6 +23,8 @@ impl Config {
1923
Ok(Self {
2024
open_browser_website_host: "https://wavedash.gg".to_string(),
2125
api_host: "https://convex-http.wavedash.gg".to_string(),
26+
keyring_service: None,
27+
keyring_account: None,
2228
})
2329
}
2430
}
@@ -32,6 +38,26 @@ pub fn get(key: &str) -> Result<String> {
3238
}
3339
}
3440

41+
#[derive(Debug)]
42+
pub struct KeyringConfig {
43+
pub service: String,
44+
pub account: String,
45+
}
46+
47+
pub fn keyring_config() -> Result<KeyringConfig> {
48+
let config = Config::load()?;
49+
Ok(KeyringConfig {
50+
service: config
51+
.keyring_service
52+
.clone()
53+
.unwrap_or_else(|| "wvdsh".to_string()),
54+
account: config
55+
.keyring_account
56+
.clone()
57+
.unwrap_or_else(|| "api-key".to_string()),
58+
})
59+
}
60+
3561
#[derive(Debug, Deserialize)]
3662
pub struct GodotSection {
3763
pub version: String,

src/main.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
mod auth;
22
mod builds;
33
mod config;
4-
mod rclone;
54

65
use anyhow::Result;
76
use clap::{Parser, Subcommand};

0 commit comments

Comments
 (0)