Skip to content

Commit

Permalink
version bumps
Browse files Browse the repository at this point in the history
  • Loading branch information
ddboline committed Apr 30, 2024
1 parent 1cc3bd0 commit 6a01a3f
Show file tree
Hide file tree
Showing 12 changed files with 90 additions and 56 deletions.
8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "sync_app_rust"
version = "0.11.12"
version = "0.11.13"
authors = ["Daniel Boline <[email protected]>"]
edition = "2018"

Expand All @@ -17,13 +17,13 @@ sync_app_http = {path = "sync_app_http"}
sync_app_lib = {path = "sync_app_lib"}
anyhow = "1.0"
dirs = "5.0"
env_logger = "0.10"
env_logger = "0.11"
futures = "0.3"
gdrive_lib = {path="gdrive_lib"}
log = "0.4"
stack-string = { git = "https://github.com/ddboline/stack-string-rs.git", features=["postgres_types"], tag="0.9.2" }
stack-string = { git = "https://github.com/ddboline/stack-string-rs.git", features=["postgres_types"], tag="0.9.3" }
time = {version="0.3", features=["serde-human-readable", "macros", "formatting"]}
tokio = {version="1.35", features=["rt", "macros", "rt-multi-thread"]}
tokio = {version="1.37", features=["rt", "macros", "rt-multi-thread"]}
walkdir = "2.3"

[workspace]
Expand Down
4 changes: 2 additions & 2 deletions gdrive_lib/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "gdrive_lib"
version = "0.11.12"
version = "0.11.13"
authors = ["Daniel Boline <[email protected]>"]
edition = "2018"

Expand All @@ -27,7 +27,7 @@ rand = "0.8"
serde = "1.0"
serde_derive = "1.0"
serde_json = "1.0"
stack-string = { git = "https://github.com/ddboline/stack-string-rs.git", features=["postgres_types"], tag="0.9.2" }
stack-string = { git = "https://github.com/ddboline/stack-string-rs.git", features=["postgres_types"], tag="0.9.3" }
stdout-channel = "0.6"
time = {version="0.3", features=["serde-human-readable", "macros", "formatting"]}
url = "2.3"
Expand Down
4 changes: 2 additions & 2 deletions gdrive_lib/src/gdrive_instance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -629,7 +629,7 @@ impl GDriveInstance {
let parents = d
.parents
.as_ref()
.and_then(|p| p.get(0).map(ToString::to_string));
.and_then(|p| p.first().map(ToString::to_string));
if parents.is_none()
&& root_id.is_none()
&& d.name != Some("Chrome Syncable FileSystem".to_string())
Expand Down Expand Up @@ -675,7 +675,7 @@ impl GDriveInstance {
let mut pid: Option<StackString> = finfo
.parents
.as_ref()
.and_then(|parents| parents.get(0).map(|p| p.to_string().into()));
.and_then(|parents| parents.first().map(|p| p.to_string().into()));
loop {
pid = if let Some(pid_) = pid.as_ref() {
if let Some(dinfo) = dirmap.get(pid_) {
Expand Down
19 changes: 10 additions & 9 deletions sync_app_http/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "sync_app_http"
version = "0.11.12"
version = "0.11.13"
authors = ["Daniel Boline <[email protected]>"]
edition = "2018"

Expand All @@ -9,25 +9,26 @@ edition = "2018"
[dependencies]
anyhow = "1.0"
async-trait = "0.1"
authorized_users = { git = "https://github.com/ddboline/auth_server_rust.git", tag="0.11.8"}
authorized_users = { git = "https://github.com/ddboline/auth_server_rust.git", tag="0.11.13"}
deadqueue = "0.2"
dioxus = "0.4"
dioxus-ssr = "0.4"
dioxus = "0.5"
dioxus-core = "0.5"
dioxus-ssr = "0.5"
dirs = "5.0"
futures = "0.3"
itertools = "0.12"
log = "0.4"
maplit = "1.0"
parking_lot = "0.12"
postgres_query = {git = "https://github.com/ddboline/rust-postgres-query", tag = "0.3.6", features=["deadpool"]}
reqwest = {version="0.11", features=["cookies", "json", "rustls-tls"], default_features=false}
rweb = {git = "https://github.com/ddboline/rweb.git", features=["openapi"], default-features=false, tag="0.15.1-1"}
rweb-helper = { git = "https://github.com/ddboline/rweb_helper.git", tag="0.5.1" }
postgres_query = {git = "https://github.com/ddboline/rust-postgres-query", tag = "0.3.7", features=["deadpool"]}
reqwest = {version="0.12", features=["cookies", "json", "rustls-tls"], default_features=false}
rweb = {git = "https://github.com/ddboline/rweb.git", features=["openapi"], default-features=false, tag="0.15.2"}
rweb-helper = { git = "https://github.com/ddboline/rweb_helper.git", tag="0.5.3" }
serde = "1.0"
serde_derive = "1.0"
serde_json = "1.0"
serde_yaml = "0.9"
stack-string = { git = "https://github.com/ddboline/stack-string-rs.git", features=["postgres_types", "rweb-openapi"], tag="0.9.2" }
stack-string = { git = "https://github.com/ddboline/stack-string-rs.git", features=["postgres_types", "rweb-openapi"], tag="0.9.3" }
stdout-channel = "0.6"
sync_app_lib = {path = "../sync_app_lib"}
thiserror = "1.0"
Expand Down
46 changes: 30 additions & 16 deletions sync_app_http/src/elements.rs
Original file line number Diff line number Diff line change
@@ -1,20 +1,29 @@
use dioxus::prelude::{
component, dioxus_elements, rsx, Element, GlobalAttributes, IntoDynNode, Props, Scope,
VirtualDom,
component, dioxus_elements, rsx, Element, GlobalAttributes, IntoDynNode, Props, VirtualDom,
};

use stack_string::StackString;
use sync_app_lib::models::{FileSyncCache, FileSyncConfig};

pub fn index_body(conf_list: Vec<FileSyncConfig>, entries: Vec<FileSyncCache>) -> String {
use crate::errors::ServiceError as Error;

/// # Errors
/// Returns error if formatting fails
pub fn index_body(
conf_list: Vec<FileSyncConfig>,
entries: Vec<FileSyncCache>,
) -> Result<String, Error> {
let mut app =
VirtualDom::new_with_props(IndexElement, IndexElementProps { conf_list, entries });
drop(app.rebuild());
dioxus_ssr::render(&app)
app.rebuild_in_place();
let mut renderer = dioxus_ssr::Renderer::default();
let mut buffer = String::new();
renderer.render_to(&mut buffer, &app)?;
Ok(buffer)
}

#[component]
fn IndexElement(cx: Scope, conf_list: Vec<FileSyncConfig>, entries: Vec<FileSyncCache>) -> Element {
fn IndexElement(conf_list: Vec<FileSyncConfig>, entries: Vec<FileSyncCache>) -> Element {
let conf_element = conf_list.iter().enumerate().filter_map(|(idx, v)| {
v.name.as_ref().map(|name| {
rsx! {
Expand Down Expand Up @@ -67,7 +76,7 @@ fn IndexElement(cx: Scope, conf_list: Vec<FileSyncConfig>, entries: Vec<FileSync
}
}
});
cx.render(rsx! {
rsx! {
head {
style {
dangerous_inner_html: include_str!("../../templates/style.css")
Expand Down Expand Up @@ -133,31 +142,36 @@ fn IndexElement(cx: Scope, conf_list: Vec<FileSyncConfig>, entries: Vec<FileSync
nav {
id: "navigation",
"start": "0",
conf_element,
{conf_element},
},
article {
id: "main_article",
entries,
{entries},
},
}
})
}
}

pub fn text_body(text: StackString) -> String {
/// # Errors
/// Returns error if formatting fails
pub fn text_body(text: StackString) -> Result<String, Error> {
let mut app = VirtualDom::new_with_props(TextElement, TextElementProps { text });
drop(app.rebuild());
dioxus_ssr::render(&app)
app.rebuild_in_place();
let mut renderer = dioxus_ssr::Renderer::default();
let mut buffer = String::new();
renderer.render_to(&mut buffer, &app)?;
Ok(buffer)
}

#[component]
fn TextElement(cx: Scope, text: StackString) -> Element {
cx.render(rsx! {
fn TextElement(text: StackString) -> Element {
rsx! {
textarea {
autofocus: "true",
readonly: "readonly",
rows: "50",
cols: "100",
"{text}",
}
})
}
}
8 changes: 7 additions & 1 deletion sync_app_http/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@ use rweb::{
};
use serde::Serialize;
use std::{
borrow::Cow, convert::Infallible, fmt::Debug, io::Error as IoError, str::Utf8Error,
borrow::Cow,
convert::Infallible,
fmt::{Debug, Error as FmtError},
io::Error as IoError,
str::Utf8Error,
string::FromUtf8Error,
};
use stdout_channel::StdoutChannelError;
Expand Down Expand Up @@ -44,6 +48,8 @@ pub enum ServiceError {
StdoutChannelError(#[from] StdoutChannelError),
#[error("PqError {0}")]
PqError(#[from] PqError),
#[error("FmtError {0}")]
FmtError(#[from] FmtError),
}

impl Reject for ServiceError {}
Expand Down
10 changes: 5 additions & 5 deletions sync_app_http/src/routes.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use futures::TryStreamExt;
use rweb::{get, Query, Rejection, post, delete};
use rweb::{delete, get, post, Query, Rejection};
use rweb_helper::{
html_response::HtmlResponse as HtmlBase, json_response::JsonResponse as JsonBase, RwebResponse,
};
Expand Down Expand Up @@ -43,7 +43,7 @@ pub async fn sync_frontpage(
.try_collect()
.await
.map_err(Into::<Error>::into)?;
let body = index_body(conf_list, entries);
let body = index_body(conf_list, entries)?;
Ok(HtmlBase::new(body).into())
}

Expand Down Expand Up @@ -231,7 +231,7 @@ pub async fn sync_podcasts(
) -> WarpResult<SyncPodcastsResponse> {
match user.push_session(SyncKey::SyncPodcast, data).await? {
Some(result) => {
let body = text_body(result.join("\n").into()).into();
let body = text_body(result.join("\n").into())?.into();
Ok(HtmlBase::new(body).into())
}
None => Ok(HtmlBase::new("running".into()).into()),
Expand All @@ -258,7 +258,7 @@ pub async fn sync_security(
) -> WarpResult<SyncSecurityLogsResponse> {
match user.push_session(SyncKey::SyncSecurity, data).await? {
Some(result) => {
let body = text_body(result.join("\n").into()).into();
let body = text_body(result.join("\n").into())?.into();
Ok(HtmlBase::new(body).into())
}
None => Ok(HtmlBase::new("running".into()).into()),
Expand All @@ -276,7 +276,7 @@ pub async fn sync_weather(
) -> WarpResult<SyncWeatherDataResponse> {
match user.push_session(SyncKey::SyncWeather, data).await? {
Some(result) => {
let body = text_body(result.join("\n").into()).into();
let body = text_body(result.join("\n").into())?.into();
Ok(HtmlBase::new(body).into())
}
None => Ok(HtmlBase::new("running".into()).into()),
Expand Down
16 changes: 8 additions & 8 deletions sync_app_lib/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "sync_app_lib"
version = "0.11.12"
version = "0.11.13"
authors = ["Daniel Boline <[email protected]>"]
edition = "2018"

Expand All @@ -16,8 +16,8 @@ bytes = "1.1"
checksums = "0.9"
clap = {version="4.0", features=["derive"]}
crossbeam-utils = "0.8"
deadpool = { version = "0.10", features=["serde", "rt_tokio_1"] }
deadpool-postgres = { version = "0.12", features=["serde"] }
deadpool = { version = "0.11", features=["serde", "rt_tokio_1"] }
deadpool-postgres = { version = "0.13", features=["serde"] }
derive_more = "0.99"
dirs = "5.0"
dotenv = "0.15"
Expand All @@ -31,25 +31,25 @@ mime = "0.3"
once_cell = "1.0"
parking_lot = "0.12"
percent-encoding = "2.1"
postgres_query = {git = "https://github.com/ddboline/rust-postgres-query", tag = "0.3.6", features=["deadpool"]}
postgres_query = {git = "https://github.com/ddboline/rust-postgres-query", tag = "0.3.7", features=["deadpool"]}
postgres-types = {version = "0.2", features = ["with-time-0_3", "with-uuid-1", "with-serde_json-1", "derive"]}
rand = "0.8"
rayon = "1.5"
refinery = {version="0.8", features=["tokio-postgres"]}
reqwest = {version="0.11", features=["cookies", "json", "rustls-tls"], default_features=false}
reqwest = {version="0.12", features=["cookies", "json", "rustls-tls"], default_features=false}
rust_decimal = "1.26"
serde = {version="1.0", features=["derive"]}
serde_json = "1.0"
smallvec = "1.6"
stack-string = { git = "https://github.com/ddboline/stack-string-rs.git", features=["postgres_types"], tag="0.9.2" }
stack-string = { git = "https://github.com/ddboline/stack-string-rs.git", features=["postgres_types"], tag="0.9.3" }
stdout-channel = "0.6"
thiserror = "1.0"
time = {version="0.3", features=["serde-human-readable", "macros", "formatting"]}
tokio = {version="1.35", features=["rt", "macros", "rt-multi-thread"]}
tokio = {version="1.37", features=["rt", "macros", "rt-multi-thread"]}
tokio-postgres = {version = "0.7", features = ["with-time-0_3", "with-uuid-1", "with-serde_json-1"]}
url = "2.3"
uuid = "1.1"
walkdir = "2.3"

[dev-dependencies]
env_logger = "0.10"
env_logger = "0.11"
2 changes: 1 addition & 1 deletion sync_app_lib/src/file_sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ impl FileSync {
let key_list: Vec<_> = proc_map.keys().cloned().collect();

for urls in group_urls(&key_list).values() {
if let Some(u0) = urls.get(0) {
if let Some(u0) = urls.first() {
let futures = urls.iter().map(|key| {
let key = key.clone();
let proc_map = proc_map.clone();
Expand Down
6 changes: 4 additions & 2 deletions sync_app_lib/src/reqwest_session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,10 @@ impl ReqwestSession {
/// # Errors
/// Return error if db query fails
pub async fn post_empty(&self, url: &Url, headers: &HeaderMap) -> Result<Response, Error> {
Self::exponential_retry(|| async move { self._post_empty(url.clone(), headers.clone()).await })
.await
Self::exponential_retry(
|| async move { self._post_empty(url.clone(), headers.clone()).await },
)
.await
}

/// # Errors
Expand Down
7 changes: 4 additions & 3 deletions sync_app_lib/src/security_sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ impl SecuritySync {

let mut output = Vec::new();

let results = match self
let results = self
.run_single_sync(
"security_log/intrusion_log",
"updates",
Expand All @@ -74,8 +74,9 @@ impl SecuritySync {
.collect()
},
)
.await
{
.await;

let results = match results {
Ok(x) => x,
Err(e) => {
error!("Recieved error, shutting down");
Expand Down
16 changes: 13 additions & 3 deletions sync_app_lib/src/sync_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,12 @@ impl SyncClient {
resp.json().await.map_err(Into::into)
}

async fn _get_remote_paginated<T: DeserializeOwned>(&self, url: &Url, offset: usize, limit: usize) -> Result<Paginated<T>, Error> {
async fn _get_remote_paginated<T: DeserializeOwned>(
&self,
url: &Url,
offset: usize,
limit: usize,
) -> Result<Paginated<T>, Error> {
let offset = format_sstr!("{offset}");
let limit = format_sstr!("{limit}");
let options = [("offset", &offset), ("limit", &limit)];
Expand All @@ -171,7 +176,12 @@ impl SyncClient {
resp.json().await.map_err(Into::into)
}

pub async fn get_remote_paginated<T: DeserializeOwned>(&self, url: &Url) -> Result<Vec<T>, Error> {
/// # Errors
/// Returns error if api call fails
pub async fn get_remote_paginated<T: DeserializeOwned>(
&self,
url: &Url,
) -> Result<Vec<T>, Error> {
let mut result = Vec::new();
let mut offset = 0;
let limit = 10;
Expand All @@ -181,7 +191,7 @@ impl SyncClient {
if total.is_none() {
total.replace(response.pagination.total);
}
if response.data.len() == 0 {
if response.data.is_empty() {
return Ok(result);
}
offset += response.data.len();
Expand Down

0 comments on commit 6a01a3f

Please sign in to comment.