Randomize names for personal profit

This commit is contained in:
Merlijn 2025-03-08 02:12:19 +01:00
parent 412cca7cde
commit a300792578
Signed by: ToxicMushroom
SSH key fingerprint: SHA256:fiv+rEfOFbxc5OPNgLT1nNCL/JndxzhkKbIJLp1JcCc
3 changed files with 11 additions and 3 deletions

1
Cargo.lock generated
View file

@ -785,6 +785,7 @@ dependencies = [
"futures-util", "futures-util",
"log", "log",
"notify-rust", "notify-rust",
"rand",
"reqwest", "reqwest",
"serde", "serde",
"serde_json", "serde_json",

View file

@ -19,3 +19,4 @@ log = "0.4.22"
notify-rust = "4.11.3" notify-rust = "4.11.3"
wl-clipboard-rs = "0.9.1" wl-clipboard-rs = "0.9.1"
async-stream = "0.3.6" async-stream = "0.3.6"
rand = "0.8.5"

View file

@ -9,8 +9,10 @@ use std::sync::{Arc, Mutex};
use clap::Parser; use clap::Parser;
use futures_util::StreamExt; use futures_util::StreamExt;
use notify_rust::{Hint, Notification, NotificationHandle}; use notify_rust::{Hint, Notification, NotificationHandle};
use rand::distributions::Alphanumeric;
use reqwest::header::{HeaderValue, AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE}; use reqwest::header::{HeaderValue, AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE};
use wl_clipboard_rs::copy::{ClipboardType, MimeType, Options, Source}; use wl_clipboard_rs::copy::{ClipboardType, MimeType, Options, Source};
use rand::{random, Rng};
type GodriveToken = String; type GodriveToken = String;
@ -218,13 +220,17 @@ async fn post_upload(
match fs::metadata(file) { match fs::metadata(file) {
Ok(metadata) => { Ok(metadata) => {
let content_length = metadata.len(); let content_length = metadata.len();
let prefix: String = rand::thread_rng()
.sample_iter(&Alphanumeric)
.take(8)
.map(char::from)
.collect();
file_infos.push(GodriveUploadObj { file_infos.push(GodriveUploadObj {
name: file name: format!("{}-{}", prefix, file
.file_name() .file_name()
.expect("You provided stupid file path") .expect("You provided stupid file path")
.to_str() .to_str()
.expect("You provided strange file path.") .expect("You provided strange file path.")),
.to_string(),
description: "".to_string(), description: "".to_string(),
overwrite: false, overwrite: false,
size: content_length, size: content_length,