diff --git a/frigate/test/test_config_migration.py b/frigate/test/test_config_migration.py index dd682c4e38..9f9226dad4 100644 --- a/frigate/test/test_config_migration.py +++ b/frigate/test/test_config_migration.py @@ -265,6 +265,18 @@ class TestMigrateConfigFile(unittest.TestCase): self.assertEqual(migrated["version"], CURRENT_CONFIG_VERSION) self.assertFalse(os.path.exists(f"{self.config_file}.tmp")) + def test_a_symlinked_config_migrates_its_target(self): + target = os.path.join(self.temp_dir.name, "frigate.yml") + with open(target, "w") as f: + f.write("mqtt:\n enabled: false\ncameras: {}\n") + os.symlink(target, self.config_file) + + migrate_frigate_config(self.config_file) + + self.assertTrue(os.path.islink(self.config_file)) + with open(target) as f: + self.assertEqual(YAML().load(f)["version"], CURRENT_CONFIG_VERSION) + def test_migrates_a_config_already_stamped_with_the_current_version(self): # 0.19 is unreleased, so a dev config can be current and still use # the pre-models keys diff --git a/frigate/util/config.py b/frigate/util/config.py index 7c83edf793..7f74f8f685 100644 --- a/frigate/util/config.py +++ b/frigate/util/config.py @@ -215,6 +215,7 @@ def find_config_file() -> str: def _write_config(config_file: str, yaml: YAML, config: dict[str, Any]) -> None: + config_file = os.path.realpath(config_file) st = os.stat(config_file) tmp_file = f"{config_file}.tmp" with open(tmp_file, "w") as f: