config: warn on file-path override across included configs
Replace silent files.extend() with explicit override detection: when a later-included config redefines a [[files]] path, warn on the console and replace in place (last definition wins, no duplicate left). Makes the previously-invisible, order-dependent config override visible.
This commit is contained in:
+21
-1
@@ -102,7 +102,27 @@ impl Config {
|
||||
self.packages.insert(package, package_config);
|
||||
}
|
||||
|
||||
self.files.extend(other_files);
|
||||
// File entries from later-included configs override earlier ones for
|
||||
// the same path. Previously this was `self.files.extend(other_files)`,
|
||||
// which silently accumulated duplicate paths and left the winner to
|
||||
// whichever entry the installer wrote last — an invisible, order-
|
||||
// dependent override that is a frequent source of "my config edit did
|
||||
// nothing" confusion (e.g. an init service redefined by a legacy
|
||||
// overlay config). Make the override explicit and visible: warn on the
|
||||
// console and replace in place so the last definition deterministically
|
||||
// wins with no duplicate left in the list.
|
||||
for file in other_files {
|
||||
if let Some(existing) = self.files.iter_mut().find(|f| f.path == file.path) {
|
||||
eprintln!(
|
||||
"config: WARNING: file '{}' redefined by a later-included config \
|
||||
(override — last definition wins)",
|
||||
file.path
|
||||
);
|
||||
*existing = file;
|
||||
} else {
|
||||
self.files.push(file);
|
||||
}
|
||||
}
|
||||
|
||||
for (user, user_config) in other_users {
|
||||
self.users.insert(user, user_config);
|
||||
|
||||
Reference in New Issue
Block a user