From 03dd9b2d42e2d39a456d84b3745b6ed082bc4ca1 Mon Sep 17 00:00:00 2001 From: Nicolas Mowen Date: Wed, 30 Oct 2024 08:22:20 -0600 Subject: [PATCH] Don't open file with read permissions if there is no need to write to it (#14689) --- frigate/config/config.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frigate/config/config.py b/frigate/config/config.py index db5e06fce..8fbb9ec6c 100644 --- a/frigate/config/config.py +++ b/frigate/config/config.py @@ -650,7 +650,7 @@ class FrigateConfig(FrigateBaseModel): migrate_frigate_config(config_path) # Finally, load the resulting configuration file. - with open(config_path, "a+") as f: + with open(config_path, "a+" if new_config else "r") as f: # Only write the default config if the opened file is non-empty. This can happen as # a race condition. It's extremely unlikely, but eh. Might as well check it. if new_config and f.tell() == 0: