Merge pull request #51 from Gusted/fix-compiling

Fix compiling
This commit is contained in:
Aravinth Manivannan 2022-10-24 21:22:34 +05:30 committed by GitHub
commit ac502b7c08
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 23 additions and 21 deletions

4
Cargo.lock generated
View File

@ -3386,9 +3386,9 @@ dependencies = [
[[package]]
name = "urlencoding"
version = "2.1.0"
version = "2.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "68b90931029ab9b034b300b797048cf23723400aa757e8a2bfb9d748102f9821"
checksum = "e8db7427f936968176eaa7cdf81b7f98b980b18495ec28f1b5791ac3bfe3eea9"
[[package]]
name = "utf-8"

View File

@ -13,7 +13,6 @@ async-trait = "0.1.51"
db-core = {path = "../db-core"}
futures = "0.3.15"
sqlx = { version = "0.5.13", features = [ "runtime-actix-rustls", "mysql", "time", "offline" ] }
urlencoding = "2.1.2"
[dev-dependencies]
actix-rt = "2"

View File

@ -68,10 +68,8 @@ impl Connect for ConnectionOptions {
async fn connect(self) -> DBResult<Self::Pool> {
let pool = match self {
Self::Fresh(fresh) => {
let mut connect_options = sqlx::mysql::MySqlConnectOptions::from_str(
&urlencoding::encode(&fresh.url),
)
.unwrap();
let mut connect_options =
sqlx::mysql::MySqlConnectOptions::from_str(&fresh.url).unwrap();
if fresh.disable_logging {
connect_options.disable_statement_logging();
}

View File

@ -13,7 +13,6 @@ async-trait = "0.1.51"
db-core = {path = "../db-core"}
futures = "0.3.15"
sqlx = { version = "0.5.13", features = [ "runtime-actix-rustls", "postgres", "time", "offline" ] }
urlencoding = "2.1.2"
[dev-dependencies]
actix-rt = "2"

View File

@ -68,10 +68,8 @@ impl Connect for ConnectionOptions {
async fn connect(self) -> DBResult<Self::Pool> {
let pool = match self {
Self::Fresh(fresh) => {
let mut connect_options = sqlx::postgres::PgConnectOptions::from_str(
&urlencoding::encode(&fresh.url),
)
.unwrap();
let mut connect_options =
sqlx::postgres::PgConnectOptions::from_str(&fresh.url).unwrap();
if fresh.disable_logging {
connect_options.disable_statement_logging();
}

View File

@ -152,15 +152,20 @@ impl Settings {
.expect("unable to set capatcha.enable_stats default config");
if let Ok(path) = env::var("MCAPTCHA_CONFIG") {
let absolute_path =
Path::new(&path).canonicalize().unwrap().to_str().unwrap();
log::info!("{}", format!("Loading config file from {}", absolute_path));
s.merge(File::with_name(absolute_path))?;
let absolute_path = Path::new(&path).canonicalize().unwrap();
log::info!(
"Loading config file from {}",
absolute_path.to_str().unwrap()
);
s.merge(File::with_name(absolute_path.to_str().unwrap()))?;
} else if Path::new(CURRENT_DIR).exists() {
let absolute_path = fs::canonicalize(CURRENT_DIR).unwrap().to_str().unwrap();
log::info!("{}", format!("Loading config file from {}", absolute_path));
let absolute_path = fs::canonicalize(CURRENT_DIR).unwrap();
log::info!(
"Loading config file from {}",
absolute_path.to_str().unwrap()
);
// merging default config from file
s.merge(File::with_name(absolute_path))?;
s.merge(File::with_name(absolute_path.to_str().unwrap()))?;
} else if Path::new(ETC).exists() {
log::info!("{}", format!("Loading config file from {}", ETC));
s.merge(File::with_name(ETC))?;
@ -220,8 +225,11 @@ fn set_database_url(s: &mut Config) {
r"postgres://{}:{}@{}:{}/{}",
s.get::<String>("database.username")
.expect("Couldn't access database username"),
s.get::<String>("database.password")
.expect("Couldn't access database password"),
urlencoding::encode(
s.get::<String>("database.password")
.expect("Couldn't access database password")
.as_str()
),
s.get::<String>("database.hostname")
.expect("Couldn't access database hostname"),
s.get::<String>("database.port")