mirror of
https://github.com/aljazceru/turso.git
synced 2026-02-18 14:35:14 +01:00
support cipher and encryption key URI options
This commit is contained in:
@@ -1277,6 +1277,12 @@ impl Connection {
|
||||
std::fs::set_permissions(&opts.path, perms.permissions())?;
|
||||
}
|
||||
let conn = db.connect()?;
|
||||
if let Some(cipher) = opts.cipher {
|
||||
let _ = conn.pragma_update("cipher", format!("'{cipher}'"));
|
||||
}
|
||||
if let Some(hexkey) = opts.hexkey {
|
||||
let _ = conn.pragma_update("hexkey", format!("'{hexkey}'"));
|
||||
}
|
||||
Ok((io, conn))
|
||||
}
|
||||
|
||||
|
||||
@@ -740,6 +740,10 @@ pub struct OpenOptions<'a> {
|
||||
pub cache: CacheMode,
|
||||
/// immutable=1|0 specifies that the database is stored on read-only media
|
||||
pub immutable: bool,
|
||||
// The encryption cipher
|
||||
pub cipher: Option<String>,
|
||||
// The encryption key in hex format
|
||||
pub hexkey: Option<String>,
|
||||
}
|
||||
|
||||
pub const MEMORY_PATH: &str = ":memory:";
|
||||
@@ -890,6 +894,8 @@ fn parse_query_params(query: &str, opts: &mut OpenOptions) -> Result<()> {
|
||||
"cache" => opts.cache = decoded_value.as_str().into(),
|
||||
"immutable" => opts.immutable = decoded_value == "1",
|
||||
"vfs" => opts.vfs = Some(decoded_value),
|
||||
"cipher" => opts.cipher = Some(decoded_value),
|
||||
"hexkey" => opts.hexkey = Some(decoded_value),
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user