mirror of
https://github.com/launchbadge/sqlx.git
synced 2026-03-19 08:39:44 +00:00
chore(sqlx-postgres): replace dirs with home & etcetera (#2485)
This commit is contained in:
@@ -50,9 +50,9 @@ atoi = "2.0"
|
||||
base64 = { version = "0.21.0", default-features = false, features = ["std"] }
|
||||
bitflags = { version = "1.3.2", default-features = false }
|
||||
byteorder = { version = "1.4.3", default-features = false, features = ["std"] }
|
||||
dirs = "4.0.0"
|
||||
dotenvy = { workspace = true }
|
||||
hex = "0.4.3"
|
||||
home = "0.5.5"
|
||||
itoa = "1.0.1"
|
||||
log = "0.4.17"
|
||||
memchr = { version = "2.4.1", default-features = false }
|
||||
@@ -71,3 +71,6 @@ serde_json = { version = "1.0.85", features = ["raw_value"] }
|
||||
workspace = true
|
||||
# We use JSON in the driver implementation itself so there's no reason not to enable it here.
|
||||
features = ["json"]
|
||||
|
||||
[target.'cfg(target_os = "windows")'.dependencies]
|
||||
etcetera = "0.8.0"
|
||||
|
||||
@@ -21,9 +21,15 @@ pub fn load_password(
|
||||
}
|
||||
|
||||
#[cfg(not(target_os = "windows"))]
|
||||
let default_file = dirs::home_dir().map(|path| path.join(".pgpass"));
|
||||
let default_file = home::home_dir().map(|path| path.join(".pgpass"));
|
||||
#[cfg(target_os = "windows")]
|
||||
let default_file = dirs::data_dir().map(|path| path.join("postgres").join("pgpass.conf"));
|
||||
let default_file = {
|
||||
use etcetera::BaseStrategy;
|
||||
|
||||
etcetera::base_strategy::Windows::new()
|
||||
.ok()
|
||||
.map(|basedirs| basedirs.data_dir().join("postgres").join("pgpass.conf"))
|
||||
};
|
||||
load_password_from_file(default_file?, host, port, username, database)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user