From f9e4d1afff2ac8bc2b3b02e1e535c8a91c30574f Mon Sep 17 00:00:00 2001 From: Alie Date: Sun, 9 Jul 2023 21:15:58 +0200 Subject: [PATCH] extracted sync with server to a shell file --- Cargo.lock | 14 +++++++------- Cargo.toml | 2 +- README.md | 7 +++---- config.toml | 2 +- src/main.rs | 45 --------------------------------------------- synced_run.sh | 10 ++++++++++ 6 files changed, 22 insertions(+), 58 deletions(-) create mode 100755 synced_run.sh diff --git a/Cargo.lock b/Cargo.lock index b45a005..8ed3278 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -24,13 +24,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a4a4ddaa51a5bc52a6948f74c06d20aaaddb71924eab79b8c97a8c556e942d6a" [[package]] -name = "bitflags" -version = "1.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" - -[[package]] -name = "booru_image_tag_curating_helper" +name = "bitch" version = "0.1.0" dependencies = [ "futures", @@ -40,6 +34,12 @@ dependencies = [ "toml", ] +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + [[package]] name = "bumpalo" version = "3.12.0" diff --git a/Cargo.toml b/Cargo.toml index 9e09905..724ea00 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "booru_image_tag_curating_helper" +name = "bitch" version = "0.1.0" edition = "2021" diff --git a/README.md b/README.md index 62332b4..e81fe8d 100644 --- a/README.md +++ b/README.md @@ -13,10 +13,9 @@ Tool for curating booru image bots - [x] Write ## Config file ### Hardcoded for now -- [ ] Tags -- [ ] Keybinds -- [ ] DB config (CSV for now) -- [ ] API URLS (MAYBE I CAN JUST CURL?) +- [x] Tags +- [x] Keybinds +- [x] DB config (CSV for now) ## Downloader - [x] Downloader (Gelbooru API) ## Uploader diff --git a/config.toml b/config.toml index f8fd3aa..a1eb123 100644 --- a/config.toml +++ b/config.toml @@ -12,4 +12,4 @@ tags = ["2girls", "sleeping"] # Routes to the files used by the program pending = "./pending.csv" rejected = "./rejected.csv" -verified = "./verified.csv" \ No newline at end of file +verified = "./urls.csv" diff --git a/src/main.rs b/src/main.rs index cf82245..9dd836e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -37,7 +37,6 @@ struct Storage { #[tokio::main] async fn main() { - pull(); let config: Config = parse_config(CONFIG); let mut arg = std::env::args().skip(1); match &arg @@ -48,8 +47,6 @@ async fn main() { "-v" => verify_mode(&config.keybinds, &config.storage), _ => {} } - - push(); } /// Parses the given filename to a config struct @@ -123,48 +120,6 @@ fn verify_mode(keybinds: &Keybinds, storage: &Storage) { std::fs::write(&storage.pending, "").unwrap(); } -fn pull() { - let mut c1 = Command::new("scp") - .arg("bot:/home/bot/sleepinggaysbot/urls.csv") - .arg("verified.csv") - .spawn() - .expect("open command failed to start"); - let mut c2 = Command::new("scp") - .arg("bot:/home/bot/sleepinggaysbot/rejected.csv") - .arg("rejected.csv") - .spawn() - .expect("open command failed to start"); - let mut c3 = Command::new("scp") - .arg("bot:/home/bot/sleepinggaysbot/pending.csv") - .arg("pending.csv") - .spawn() - .expect("open command failed to start"); - c1.wait().unwrap(); - c2.wait().unwrap(); - c3.wait().unwrap(); -} - -fn push() { - let mut c1 = Command::new("scp") - .arg("verified.csv") - .arg("bot:/home/bot/sleepinggaysbot/urls.csv") - .spawn() - .expect("open command failed to start"); - let mut c2 = Command::new("scp") - .arg("rejected.csv") - .arg("bot:/home/bot/sleepinggaysbot/rejected.csv") - .spawn() - .expect("open command failed to start"); - let mut c3 = Command::new("scp") - .arg("pending.csv") - .arg("bot:/home/bot/sleepinggaysbot/pending.csv") - .spawn() - .expect("open command failed to start"); - c1.wait().unwrap(); - c2.wait().unwrap(); - c3.wait().unwrap(); -} - fn input_parse(storage: &Storage, keybinds: &Keybinds, image_uri: &str) -> bool { loop { let key = std::io::stdin() diff --git a/synced_run.sh b/synced_run.sh new file mode 100755 index 0000000..0f9a9dc --- /dev/null +++ b/synced_run.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +rsync -v\ + bot:/home/bot/sleepinggaysbot/*.csv\ + . &&\ +bitch $@ &&\ +rsync -v\ + *.csv\ + bot:/home/bot/sleepinggaysbot/ +