mirror of
https://codeberg.org/icewind/nextcloud-config-parser.git
synced 2026-06-03 16:44:09 +02:00
handle redis db index as str
This commit is contained in:
parent
9ada18d5a6
commit
484af6a8e7
5 changed files with 31 additions and 3 deletions
2
Cargo.lock
generated
2
Cargo.lock
generated
|
|
@ -836,7 +836,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "nextcloud-config-parser"
|
||||
version = "0.14.0"
|
||||
version = "0.14.1"
|
||||
dependencies = [
|
||||
"form_urlencoded",
|
||||
"itertools",
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
[package]
|
||||
name = "nextcloud-config-parser"
|
||||
description = "Rust parser for nextcloud config files"
|
||||
version = "0.14.0"
|
||||
version = "0.14.1"
|
||||
authors = ["Robin Appelman <robin@icewind.nl>"]
|
||||
edition = "2021"
|
||||
license = "MIT OR Apache-2.0"
|
||||
|
|
|
|||
|
|
@ -331,7 +331,11 @@ fn parse_redis_options(parsed: &Value, key: &str) -> RedisConfig {
|
|||
None
|
||||
};
|
||||
|
||||
let db = redis_options["dbindex"].clone().into_int().unwrap_or(0);
|
||||
let db = redis_options["dbindex"].clone().into_int().or_else(|| {
|
||||
redis_options["dbindex"]
|
||||
.as_str()
|
||||
.and_then(|i| i64::from_str(i).ok())
|
||||
}).unwrap_or(0);
|
||||
let password = redis_options["password"]
|
||||
.as_str()
|
||||
.filter(|pass| !pass.is_empty())
|
||||
|
|
|
|||
|
|
@ -108,6 +108,15 @@ fn test_parse_redis_socket() {
|
|||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_parse_redis_db_str() {
|
||||
let config = config_from_file("tests/configs/redis_db_str.php");
|
||||
assert_debug_equal(
|
||||
RedisConfig::Single(parse_redis("redis://127.0.0.1/1")),
|
||||
config.redis,
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_parse_notify_push_redis() {
|
||||
let config = config_from_file("tests/configs/notify_push_redis.php");
|
||||
|
|
|
|||
15
tests/configs/redis_db_str.php
Normal file
15
tests/configs/redis_db_str.php
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
<?php
|
||||
|
||||
$CONFIG = [
|
||||
'overwrite.cli.url' => 'https://cloud.example.com',
|
||||
'dbtype' => 'mysql',
|
||||
'dbname' => 'nextcloud',
|
||||
'dbhost' => 'localhost',
|
||||
'dbport' => '',
|
||||
'dbuser' => 'nextcloud',
|
||||
'dbpassword' => 'secret',
|
||||
'redis' => [
|
||||
'host' => 'localhost',
|
||||
'dbindex' => '1',
|
||||
]
|
||||
];
|
||||
Loading…
Add table
Add a link
Reference in a new issue