From 0d6235792f7d24590bfc44b2f11987d831231206 Mon Sep 17 00:00:00 2001 From: by22Jy <122969909+by22Jy@users.noreply.github.com> Date: Thu, 26 Feb 2026 13:21:40 +0800 Subject: [PATCH] Fix: Allow database update when file doesn't exist The --update-database command should create the database file if it doesn't exist, but the current implementation raises an error before attempting the download. This fix changes the validation logic to only check if existing files are writeable, allowing the download logic to create the file and parent directories as needed. Fixes #2689 --- intelmq/bots/experts/asn_lookup/expert.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/intelmq/bots/experts/asn_lookup/expert.py b/intelmq/bots/experts/asn_lookup/expert.py index 008e291dc..6b1cf5bf5 100644 --- a/intelmq/bots/experts/asn_lookup/expert.py +++ b/intelmq/bots/experts/asn_lookup/expert.py @@ -123,10 +123,12 @@ def update_database(cls, verbose=False): raise MissingDependencyError("pyasn") for database_path in set(bots.values()): - if not Path(database_path).is_file(): - raise ValueError('Database file does not exist or is not a file.') - elif not os.access(database_path, os.W_OK): - raise ValueError('Database file is not writeable.') + database_file = Path(database_path) + if database_file.is_file(): + # File exists, check if it's writeable + if not os.access(database_path, os.W_OK): + raise ValueError('Database file is not writeable.') + # If file doesn't exist, the directory will be created later when downloading try: if verbose: