This commit is contained in:
Robin Appelman 2026-03-02 22:22:45 +01:00
commit bb16d30aa2
6 changed files with 410 additions and 469 deletions

823
Cargo.lock generated

File diff suppressed because it is too large Load diff

View file

@ -1,17 +1,17 @@
[package]
name = "nextcloud-config-parser"
description = "Rust parser for nextcloud config files"
version = "0.14.1"
version = "0.15.0"
authors = ["Robin Appelman <robin@icewind.nl>"]
edition = "2021"
license = "MIT OR Apache-2.0"
repository = "https://codeberg.org/icewind/nextcloud-config-parser"
documentation = "https://docs.rs/nextcloud-config-parser"
rust-version = "1.81.0"
rust-version = "1.88.0"
[dependencies]
thiserror = "2.0.11"
php-literal-parser = "0.6.2"
php-literal-parser = "0.7.1"
miette = "7.4.0"
urlencoding = "2.1.3"
form_urlencoded = "1.2.1"
@ -21,4 +21,4 @@ indexmap = "2.13.0"
[dev-dependencies]
miette = { version = "7.4.0", features = ["fancy"] }
sqlx = { version = "0.8.3", default-features = false, features = ["any", "mysql", "sqlite", "postgres"] }
redis = "0.30.0"
redis = "1.0.4"

34
flake.lock generated
View file

@ -2,11 +2,11 @@
"nodes": {
"crane": {
"locked": {
"lastModified": 1751562746,
"narHash": "sha256-smpugNIkmDeicNz301Ll1bD7nFOty97T79m4GUMUczA=",
"lastModified": 1763938834,
"narHash": "sha256-j8iB0Yr4zAvQLueCZ5abxfk6fnG/SJ5JnGUziETjwfg=",
"owner": "ipetkov",
"repo": "crane",
"rev": "aed2020fd3dc26e1e857d4107a5a67a33ab6c1fd",
"rev": "d9e753122e51cee64eb8d2dddfe11148f339f5a2",
"type": "github"
},
"original": {
@ -22,11 +22,11 @@
]
},
"locked": {
"lastModified": 1754312187,
"narHash": "sha256-rKR+JuAX+sOhaW9glu2DIJlV1YHU7X04Wjt/hYGGfzs=",
"lastModified": 1772457021,
"narHash": "sha256-TCVI5o3/v/fsLYZhwI7Jp52GVdNq4P/qiAP/B3ww7do=",
"owner": "nix-community",
"repo": "flakelight",
"rev": "5286275afda277d16d7bda8c6ad4c27649eecf95",
"rev": "c576dab67cdcdc28e81a85f5f1c9c5743742144e",
"type": "github"
},
"original": {
@ -44,11 +44,11 @@
"rust-overlay": "rust-overlay"
},
"locked": {
"lastModified": 1752438127,
"narHash": "sha256-1NKLbztqg0/sYUhZgxus+WJU+jZThkV+pga/kqjB3/A=",
"lastModified": 1772297202,
"narHash": "sha256-UEzHO/tCmhPhr8RpWtbm1MTa7ABobwt3nCjrcuDAPm0=",
"ref": "refs/heads/main",
"rev": "31877680aa6d391e59a598d35081e24b4316ab9a",
"revCount": 60,
"rev": "8690e1514863b934de12f2a503c9431d186ce30b",
"revCount": 68,
"type": "git",
"url": "https://codeberg.org/icewind/mill-scale.git"
},
@ -59,16 +59,16 @@
},
"nixpkgs": {
"locked": {
"lastModified": 1754292888,
"narHash": "sha256-1ziydHSiDuSnaiPzCQh1mRFBsM2d2yRX9I+5OPGEmIE=",
"lastModified": 1772047000,
"narHash": "sha256-7DaQVv4R97cii/Qdfy4tmDZMB2xxtyIvNGSwXBBhSmo=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "ce01daebf8489ba97bd1609d185ea276efdeb121",
"rev": "1267bb4920d0fc06ea916734c11b0bf004bbe17e",
"type": "github"
},
"original": {
"id": "nixpkgs",
"ref": "nixos-25.05",
"ref": "nixos-25.11",
"type": "indirect"
}
},
@ -88,11 +88,11 @@
]
},
"locked": {
"lastModified": 1752374969,
"narHash": "sha256-Ky3ynEkJXih7mvWyt9DWoiSiZGqPeHLU1tlBU4b0mcc=",
"lastModified": 1764557621,
"narHash": "sha256-kX5PoY8hQZ80+amMQgOO9t8Tc1JZ70gYRnzaVD4AA+o=",
"owner": "oxalica",
"repo": "rust-overlay",
"rev": "75fb000638e6d0f57cb1e8b7a4550cbdd8c76f1d",
"rev": "93316876c2229460a5d6f5f052766cc4cef538ce",
"type": "github"
},
"original": {

View file

@ -1,6 +1,6 @@
{
inputs = {
nixpkgs.url = "nixpkgs/nixos-25.05";
nixpkgs.url = "nixpkgs/nixos-25.11";
flakelight = {
url = "github:nix-community/flakelight";
inputs.nixpkgs.follows = "nixpkgs";

View file

@ -5,7 +5,6 @@ use crate::{
use crate::{RedisConfig, RedisConnectionAddr};
use indexmap::IndexMap;
use php_literal_parser::Value;
use std::collections::HashMap;
use std::fs::DirEntry;
use std::iter::once;
use std::net::IpAddr;
@ -73,10 +72,10 @@ fn parse_php(path: impl AsRef<Path>) -> Result<Value> {
}
fn merge_configs(input: Vec<(PathBuf, Value)>) -> Result<Value> {
let mut merged = HashMap::with_capacity(16);
let mut merged = IndexMap::with_capacity(16);
for (path, config) in input {
match config.into_hashmap() {
match config.into_map() {
Some(map) => {
for (key, value) in map {
merged.insert(key, value);

View file

@ -24,7 +24,7 @@ fn config_from_file(path: &str) -> Config {
fn parse_redis(cfg: &str) -> RedisConnectionInfo {
let redis = ConnectionInfo::from_str(cfg).unwrap();
let addr = match redis.addr {
let addr = match redis.addr().clone() {
ConnectionAddr::Tcp(host, port) => RedisConnectionAddr::Tcp {
host,
port,
@ -36,12 +36,17 @@ fn parse_redis(cfg: &str) -> RedisConnectionInfo {
tls: true,
},
ConnectionAddr::Unix(path) => RedisConnectionAddr::Unix { path },
_ => RedisConnectionAddr::Tcp {
host: "127.0.0.1".into(),
port: 6379,
tls: false,
},
};
RedisConnectionInfo {
addr,
db: redis.redis.db,
username: redis.redis.username,
password: redis.redis.password,
db: redis.redis_settings().db(),
username: redis.redis_settings().username().map(String::from),
password: redis.redis_settings().password().map(String::from),
tls_params: None,
}
}